.NET Framework Class Library
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)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    port As Integer _
)
Visual Basic (Usage)
Dim port As Integer

Dim instance As New TcpChannel(port)
C#
public TcpChannel (
    int port
)
C++
public:
TcpChannel (
    int port
)
J#
public TcpChannel (
    int port
)
JScript
public function TcpChannel (
    port : int
)

Parameters

port

The port on which the server channel listens.

Remarks

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.

Example

The following code example demonstrates using this method. To request that an available port be dynamically assigned, set the port parameter to zero.

Visual Basic
' Registers the server and waits until the user hits enter.
Dim chan As 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()
C#
// 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();
C++
// 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();
J#
// 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();
.NET Framework Security

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .
Platforms

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Version Information

.NET Framework

Supported in: 2.0, 1.1, 1.0
See Also

Tags :


Page view tracker