2 // System.Runtime.Remoting.Channels.Tcp.TcpClientChannel.cs
4 // Author: Dietmar Maurer (dietmar@ximian.com)
5 // Lluis Sanchez Gual (lluis@ideary.com)
7 // 2002 (C) Copyright, Ximian, Inc.
10 using System.Collections;
12 using System.Net.Sockets;
13 using System.Runtime.Remoting.Messaging;
14 using System.Runtime.Remoting.Channels;
15 using System.Threading;
17 namespace System.Runtime.Remoting.Channels.Tcp
19 public class TcpClientChannel : IChannelSender, IChannel
23 IClientChannelSinkProvider _sinkProvider;
25 public TcpClientChannel ()
29 public TcpClientChannel (IDictionary properties, IClientChannelSinkProvider sinkProvider)
31 object val = properties ["name"];
32 if (val != null) name = val as string;
34 val = properties ["priority"];
35 if (val != null) priority = Convert.ToInt32 (val);
37 if (sinkProvider != null)
39 _sinkProvider = sinkProvider;
41 // add the tcp provider at the end of the chain
42 IClientChannelSinkProvider prov = sinkProvider;
43 while (prov.Next != null) prov = prov.Next;
44 prov.Next = new TcpClientTransportSinkProvider ();
46 // Note: a default formatter is added only when
47 // no sink providers are specified in the config file.
51 _sinkProvider = new BinaryClientFormatterSinkProvider ();
52 _sinkProvider.Next = new TcpClientTransportSinkProvider ();
57 public TcpClientChannel (string name, IClientChannelSinkProvider sinkProvider)
60 _sinkProvider = sinkProvider;
62 // add the tcp provider at the end of the chain
63 IClientChannelSinkProvider prov = sinkProvider;
64 while (prov.Next != null) prov = prov.Next;
65 prov.Next = new TcpClientTransportSinkProvider ();
68 public string ChannelName
75 public int ChannelPriority
82 public IMessageSink CreateMessageSink (string url,
83 object remoteChannelData,
86 if (url == null && remoteChannelData != null) {
87 IChannelDataStore ds = remoteChannelData as IChannelDataStore;
88 if (ds != null && ds.ChannelUris.Length > 0)
89 url = ds.ChannelUris [0];
96 if (Parse (url, out objectURI) == null)
99 return (IMessageSink) _sinkProvider.CreateSink (this, url, remoteChannelData);
102 public string Parse (string url, out string objectURI)
104 return TcpChannel.ParseChannelUrl (url, out objectURI);