TcpChannel Constructor (Int32)
Initializes a new instance of the TcpChannel class with a server channel that listens on the specified port.
Assembly: System.Runtime.Remoting (in System.Runtime.Remoting.dll)
To request that the remoting system choose an open port on your behalf, specify port 0 (zero). This will create a TcpServerChannel instance to listen for requests on the dynamically assigned port. This is typically done on the client to make sure that a TcpServerChannel is listening for callback methods.
If 0 is passed to the constructor the TcpChannel is instantiated to use a free port.
The following code example demonstrates using this method. To request that an available port be dynamically assigned, set the port parameter to zero.
// Registers the server and waits until the user hits enter. TcpChannel chan = new TcpChannel(8084); ChannelServices.RegisterChannel(chan); RemotingConfiguration.RegisterWellKnownServiceType(Type.GetType("HelloServer,server"), "SayHello", WellKnownObjectMode.SingleCall); System.Console.WriteLine("Hit <enter> to exit..."); System.Console.ReadLine();
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.