TcpChannel.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // System.Runtime.Remoting.Channels.Tcp.TcpChannel.cs
  3. //
  4. // Author: Rodrigo Moya ([email protected])
  5. //
  6. // 2002 (C) Copyright, Ximian, Inc.
  7. //
  8. using System.Collections;
  9. using System.Runtime.Remoting.Messaging;
  10. using System.Text.RegularExpressions;
  11. namespace System.Runtime.Remoting.Channels.Tcp
  12. {
  13. public class TcpChannel : IChannelReceiver, IChannel,
  14. IChannelSender
  15. {
  16. private int tcp_port;
  17. public TcpChannel ()
  18. {
  19. tcp_port = 0;
  20. }
  21. public TcpChannel (int port)
  22. {
  23. tcp_port = port;
  24. }
  25. [MonoTODO]
  26. public TcpChannel (IDictionary properties,
  27. IClientChannelSinkProvider clientSinkProvider,
  28. IServerChannelSinkProvider serverSinkProvider)
  29. {
  30. throw new NotImplementedException ();
  31. }
  32. public object ChannelData
  33. {
  34. [MonoTODO]
  35. get {
  36. throw new NotImplementedException ();
  37. }
  38. }
  39. public string ChannelName
  40. {
  41. [MonoTODO]
  42. get {
  43. throw new NotImplementedException ();
  44. }
  45. }
  46. public int ChannelPriority
  47. {
  48. [MonoTODO]
  49. get {
  50. throw new NotImplementedException ();
  51. }
  52. }
  53. [MonoTODO]
  54. public IMessageSink CreateMessageSink (string url,
  55. object remoteChannelData,
  56. out string objectURI)
  57. {
  58. throw new NotImplementedException ();
  59. }
  60. [MonoTODO]
  61. public string[] GetUrlsForUri (string objectURI)
  62. {
  63. throw new NotImplementedException ();
  64. }
  65. public string Parse (string url, out string objectURI)
  66. {
  67. int port;
  68. string host = ParseTcpURL (url, out objectURI, out port);
  69. return "tcp://" + host + ":" + port;
  70. }
  71. [MonoTODO]
  72. public void StartListening (object data)
  73. {
  74. throw new NotImplementedException ();
  75. }
  76. [MonoTODO]
  77. public void StopListening (object data)
  78. {
  79. throw new NotImplementedException ();
  80. }
  81. internal static string ParseTcpURL (string url, out string objectURI, out int port)
  82. {
  83. // format: "tcp://host:port/path/to/object"
  84. objectURI = null;
  85. port = 0;
  86. Match m = Regex.Match (url, "tcp://([^:]+):([0-9]+)(/.*)");
  87. if (!m.Success)
  88. return null;
  89. string host = m.Groups[1].Value;
  90. string port_str = m.Groups[2].Value;
  91. objectURI = m.Groups[3].Value;
  92. port = Convert.ToInt32 (port_str);
  93. return host;
  94. }
  95. }
  96. }