System.Runtime.Remoting.Channels.Tcp.TcpClientChannel Class

Assembly: System.Runtime.Remoting.dll
Namespace: System.Runtime.Remoting.Channels.Tcp
Summary
Provides an implementation for a client channel that uses the TCP protocol to transmit messages.
C# Syntax:
public class TcpClientChannel : IChannelSender, IChannel
Remarks
By default, the TcpClientChannel uses a binary formatter to serialize all messages to a binary stream and transports the stream to the target URI using the TCP protocol.

Channels transport messages between applications across remoting boundaries (for example application domains, processes, and machines). The current channel sends outbound messages to an endpoint specified by the message. TcpClientChannel converts the messages sent along it to binary format, and sends them using the TCP protocol.

If there are common language runtimes at both ends of the channel, then a session is created between the two ends, in order to connect the client and server sink chains on either side of the boundary together. The client channel is located at the end of the client context sink chain. The server channel is located at the start of the server context sink chain. Messages are delivered to the client channel, travel through it, and are received by an instance of the TcpServerChannel class. The server channel then deserializes the messages and delivers them to the first server context sink.

IChannel implementations use channel configuration properties to configure the channel at run time. Channel properties can be specified in a configuration file, or programmatically, inside of an IDictionary. In a configuration file all values are represented by strings, but when building a property IDictionary programmatically, value types can be specified with their native values or with strings.

The following table shows the channel configuration properties that can be specified for the current channel.



Property Description
name Indicates the name of the channel. This property is used to retrieve a specific channel when calling ChannelServices.GetChannel . If this property is not set, the system defaults to "http". If you want to register more than one HttpChannel , each must have a unique name. Set this property to the String.Empty string ("") if you want to ignore names, but avoid naming collisions. The system will allow any number of channels with the String.Empty name.
priority An integer representing the priority assigned to this channel. Higher numbers indicate a higher chance of being chosen to connect first. The default priority is 1, and negative numbers are allowed.
machineName A string that specifies the machine name used with the current channel. Overrides the machine name channel data object.
See also:
System.Runtime.Remoting.Channels.Tcp Namespace

System.Runtime.Remoting.Channels.Tcp.TcpClientChannel Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the TcpClientChannel class with default values.
ctor #2 Overloaded:
.ctor(IDictionary properties, IClientChannelSinkProvider sinkProvider)

Initializes a new instance of the TcpClientChannel class with the specified channel properties and IClientChannelSinkProvider.
ctor #3 Overloaded:
.ctor(string name, IClientChannelSinkProvider sinkProvider)

Initializes a new instance of the TcpClientChannel class with the provided name and IClientChannelSinkProvider.
Public Properties
ChannelName Read-only

Gets the name of the current channel.
ChannelPriority Read-only

Returns the priority of the current channel.
Public Methods
CreateMessageSink Returns a channel message sink that delivers messages to the specified URL or channel data object.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
Parse Extracts the channel URI and the remote well-known object URI from the specified URL.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Runtime.Remoting.Channels.Tcp.TcpClientChannel Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the TcpClientChannel class with default values.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public TcpClientChannel();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the TcpClientChannel class with the specified channel properties and IClientChannelSinkProvider.
C# Syntax:
public TcpClientChannel(
   IDictionary properties,
   IClientChannelSinkProvider sinkProvider
);
Parameters:

properties

An IDictionary of the channel properties that hold the configuration information for the current channel.

sinkProvider

The IClientChannelSinkProvider to use with the new instance of the TcpClientChannel.

Exceptions
Exception Type Condition
ArgumentException A provided channel property was badly formatted.
Remarks


Note Channel properties are used to configure the channel at run time. For a list of possible channel properties and an example, see the conceptual topic at MSDN: channelformatterconfigurationproperties.
See also:
MSDN: channelformatterconfigurationproperties

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the TcpClientChannel class with the provided name and IClientChannelSinkProvider.
C# Syntax:
public TcpClientChannel(
   string name,
   IClientChannelSinkProvider sinkProvider
);
Parameters:

name

The name of the new instance of the TcpClientChannel.

sinkProvider

The IClientChannelSinkProvider to use with the new instance of the TcpClientChannel.

Return to top


Property: ChannelName (read-only)
Summary
Gets the name of the current channel.
C# Syntax:
public string ChannelName {get;}
Implements:
IChannel.ChannelName
Remarks
This property is used to retrieve a specific channel when calling ChannelServices.GetChannel. If this property is not set, the system defaults to "tcp". If you want to register more than one TcpClientChannel, each must have a unique name. Set this property to the String.Empty string ("") if you want to ignore names, but avoid naming collisions. The system will allow any number of channels with the String.Empty name.

Return to top


Property: ChannelPriority (read-only)
Summary
Returns the priority of the current channel.
C# Syntax:
public int ChannelPriority {get;}
Implements:
IChannel.ChannelPriority
Remarks
Channels with a larger priority number have the first opportunity to connect to a given endpoint. The default priority is 1, and negative numbers are allowed.

Return to top


Method: CreateMessageSink(
   string url,
   object remoteChannelData,
   out string objectURI
)
Summary
Returns a channel message sink that delivers messages to the specified URL or channel data object.
C# Syntax:
public virtual IMessageSink CreateMessageSink(
   string url,
   object remoteChannelData,
   out string objectURI
);
Parameters:

url

The URL to which the new sink will deliver messages. Can be null.

remoteChannelData

The channel data object of the remote host to which the new sink will deliver messages. Can be null.

objectURI

When this method returns, contains a URI of the new channel message sink that delivers messages to the specified URL or channel data object. This parameter is passed uninitialized.

Return Value:
A channel message sink, that delivers messages to the specified URL or channel data object.
Implements:
IChannelSender.CreateMessageSink
Remarks
The TcpClientChannel.CreateMessageSink method returns a channel message sink that delivers messages to either the specified URL or channel data object. If the uri parameter is null, remoteChannelData is used as a target for the sink. Either the url or remoteChannelData parameters can be null, but not both.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~TcpClientChannel();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Parse(
   string url,
   out string objectURI
)
Summary
Extracts the channel URI and the remote well-known object URI from the specified URL.
C# Syntax:
public string Parse(
   string url,
   out string objectURI
);
Parameters:

url

The URL from which to extract the URIs.

objectURI

When this method returns, contains a String that holds the URI of the remote well-known object. This parameter is passed uninitialized.

Return Value:
The channel URI.
Implements:
IChannel.Parse

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.