TcpChannel Constructores

Definición

Inicializa una nueva instancia de la clase TcpChannel.

Sobrecargas

Nombre Description
TcpChannel()

Inicializa una nueva instancia de la TcpChannel clase , activando solo un canal de cliente y no un canal de servidor.

TcpChannel(Int32)

Inicializa una nueva instancia de la TcpChannel clase con un canal de servidor que escucha en el puerto especificado.

TcpChannel(IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider)

Inicializa una nueva instancia de la TcpChannel clase con las propiedades y receptores de configuración especificados.

TcpChannel()

Inicializa una nueva instancia de la TcpChannel clase , activando solo un canal de cliente y no un canal de servidor.

public:
 TcpChannel();
public TcpChannel();
Public Sub New ()

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar este constructor.

// Create the channel.
TcpChannel^ clientChannel = gcnew TcpChannel();
// Create the channel.
TcpChannel clientChannel = new TcpChannel();

Comentarios

El constructor sin parámetros inicializa todos los campos en sus valores predeterminados. Si se usa el constructor sin parámetros, el canal solo funciona como canal de cliente y no escucha en ningún puerto.

Se aplica a

TcpChannel(Int32)

Inicializa una nueva instancia de la TcpChannel clase con un canal de servidor que escucha en el puerto especificado.

public:
 TcpChannel(int port);
public TcpChannel(int port);
new System.Runtime.Remoting.Channels.Tcp.TcpChannel : int -> System.Runtime.Remoting.Channels.Tcp.TcpChannel
Public Sub New (port As Integer)

Parámetros

port
Int32

Puerto en el que escucha el canal del servidor.

Ejemplos

En el ejemplo de código siguiente se muestra el uso de este método. Para solicitar que se asigne dinámicamente un puerto disponible, establezca el port parámetro en cero.

// 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();
// 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();
' 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()

Comentarios

Para solicitar que el sistema de comunicación remota elija un puerto abierto en su nombre, especifique el puerto 0 (cero). Esto creará una TcpServerChannel instancia para escuchar las solicitudes en el puerto asignado dinámicamente. Normalmente, esto se hace en el cliente para asegurarse de que está TcpServerChannel escuchando métodos de devolución de llamada.

Si se pasa 0 al constructor, TcpChannel se crea una instancia de para usar un puerto libre.

Se aplica a

TcpChannel(IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider)

Inicializa una nueva instancia de la TcpChannel clase con las propiedades y receptores de configuración especificados.

public:
 TcpChannel(System::Collections::IDictionary ^ properties, System::Runtime::Remoting::Channels::IClientChannelSinkProvider ^ clientSinkProvider, System::Runtime::Remoting::Channels::IServerChannelSinkProvider ^ serverSinkProvider);
public TcpChannel(System.Collections.IDictionary properties, System.Runtime.Remoting.Channels.IClientChannelSinkProvider clientSinkProvider, System.Runtime.Remoting.Channels.IServerChannelSinkProvider serverSinkProvider);
new System.Runtime.Remoting.Channels.Tcp.TcpChannel : System.Collections.IDictionary * System.Runtime.Remoting.Channels.IClientChannelSinkProvider * System.Runtime.Remoting.Channels.IServerChannelSinkProvider -> System.Runtime.Remoting.Channels.Tcp.TcpChannel
Public Sub New (properties As IDictionary, clientSinkProvider As IClientChannelSinkProvider, serverSinkProvider As IServerChannelSinkProvider)

Parámetros

properties
IDictionary

Colección IDictionary que especifica valores para las propiedades de configuración que usarán los canales de cliente y servidor.

clientSinkProvider
IClientChannelSinkProvider

Implementación IClientChannelSinkProvider que va a usar el canal de cliente.

serverSinkProvider
IServerChannelSinkProvider

Implementación IServerChannelSinkProvider que va a usar el canal de servidor.

Excepciones

Se ha aplicado un formato incorrecto a una propiedad de canal proporcionada.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar este constructor.

// Specify the properties for the server channel.
System::Collections::IDictionary^ dict = gcnew System::Collections::Hashtable;
dict[ "port" ] = 9090;
dict[ "authenticationMode" ] = "IdentifyCallers";

// Set up the server channel.
TcpChannel^ serverChannel = gcnew TcpChannel( dict,nullptr,nullptr );
ChannelServices::RegisterChannel( serverChannel );
// Specify the properties for the server channel.
System.Collections.IDictionary dict =
    new System.Collections.Hashtable();
dict["port"] = 9090;
dict["authenticationMode"] = "IdentifyCallers";

// Set up the server channel.
TcpChannel serverChannel = new TcpChannel(dict, null, null);
ChannelServices.RegisterChannel(serverChannel);

Comentarios

Los receptores de canal proporcionan un punto de complemento que permite el acceso a los mensajes subyacentes que fluyen a través del canal, así como la secuencia utilizada por el mecanismo de transporte para enviar mensajes a un objeto remoto. Los receptores de canal también son responsables de transportar mensajes entre el cliente y el servidor. Los receptores de canal se vinculan juntos en una cadena y todos los mensajes de canal fluyen a través de esta cadena de receptores antes de que el mensaje se serialice y transporte por fin. Si no necesita funcionalidad de receptor, establezca los clientSinkProvider parámetros y serverSinkProvider en null.

Se aplica a