This documentation is archived and is not being maintained.

TcpChannel Constructor (Int32)

Initializes a new instance of the TcpChannel class with a server channel that listens on the specified port.

Namespace:  System.Runtime.Remoting.Channels.Tcp
Assembly:  System.Runtime.Remoting (in System.Runtime.Remoting.dll)

public:
TcpChannel(
	int port
)

Parameters

port
Type: System::Int32
The port on which the server channel listens.

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 = gcnew TcpChannel( 8084 );
ChannelServices::RegisterChannel( chan );

RemotingConfiguration::RegisterWellKnownServiceType(
   Type::GetType( "HelloServer,server" ),
   "SayHello",
   WellKnownObjectMode::SingleCall );
System::Console::WriteLine( L"Hit <enter> to exit..." );
System::Console::ReadLine();


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.
Show: