public class TcpServerChannel : IChannelReceiver, IChannel
|
Channels transport messages between applications across remoting boundaries (for example application domains, processes, and machines). These crossings include both inbound and outbound. The current channel listens on an endpoint for inbound messages. TcpServerChannel converts the messages sent along using the TCP protocol from binary format into message objects.
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 part of the channel is located at the end of the client context sink chain. The server part of the 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. The channel then delivers received and deserialized messages 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. For server channels, the priority controls the order in which the channel data appears in an ObjRef . Clients will try to connect to the server channels in the order that they are listed in the ObjRef . The default priority is 1, and negative numbers are allowed. The default priority is 1, and negative numbers are allowed. |
port | An integer specifying the port on which the channel will listen. |
supressChannelData | true or false . Specifies that the channel will not contribute to the HttpChannel.ChannelData . |
useIpAddress | true or false . Specifies whether the channel will use the IP address in the publication URL instead of the computer name. |
rejectRemoteRequests | true or false . Specifies whether to refuse requests originating from other computers. Specifying true allows only inter- AppDomain calls on the local computer. |
bindTo | An IP address resolving to the current computer that specifies which NIC to bind the current channel to. |
machineName | A string that specifies the machine name used with the current channel. Overrides the useIpAddress configuration property and the machine name channel data. |
ctor #1 | Overloaded:.ctor(int port) Initializes a new instance of the TcpServerChannel class at the specified port. |
ctor #2 | Overloaded:.ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider) Initializes a new instance of the TcpServerChannel class with the specified channel properties and the provided IServerChannelSinkProvider. |
ctor #3 | Overloaded:.ctor(string name, int port) Initializes a new instance of the TcpServerChannel class with the given name at the specified port. |
ctor #4 | Overloaded:.ctor(string name, int port, IServerChannelSinkProvider sinkProvider) Initializes a new instance of the TcpServerChannel class at the specified port with the given name and IServerChannelSinkProvider. |
ChannelData | Read-only Gets the channel specific data. |
ChannelName | Read-only Gets the name of the current channel. |
ChannelPriority | Read-only Returns the priority of the current channel. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetChannelUri | Returns the URI of the current channel. |
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. |
GetUrlsForUri | Returns an array of all the URLs for an object with the specified URI, hosted on the current TcpChannel. |
Parse | Extracts the channel URI and the remote well-known object URI from the specified URL. |
StartListening | Instructs the current channel to start listening for requests. |
StopListening | Instructs the current channel to stop listening for requests. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
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:
public TcpServerChannel( |
port
public TcpServerChannel( |
properties
sinkProvider
Exception Type | Condition |
---|---|
ArgumentException | A provided channel property was badly formatted. |
name
port
public TcpServerChannel( |
name
port
sinkProvider
public object ChannelData {get;}
|
public string ChannelName {get;}
|
public int ChannelPriority {get;}
|
~TcpServerChannel(); |
public string GetChannelUri(); |
public virtual int GetHashCode(); |
public Type GetType(); |
objectUri
using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels.Tcp; class Class1 { public static void Main() { // Create a remotable object. TcpServerChannel tcpChannel = new TcpServerChannel(8085); WellKnownServiceTypeEntry WKSTE = new WellKnownServiceTypeEntry(typeof(HelloService), "Service", WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType(WKSTE); RemotingConfiguration.ApplicationName = "HelloServer"; // Print out the urls for the HelloServer. string[] urls = tcpChannel.GetUrlsForUri("HelloServer"); foreach (string url in urls) System.Console.WriteLine("{0}", url); } }
protected object MemberwiseClone(); |
url
objectURI
public void StartListening( |
data
public void StopListening( |
data
public virtual string ToString(); |