Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 2.0
TcpChannel Class
 TcpChannel Constructor (Int32)

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.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)

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.

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.

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();
  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

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.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker