TcpChannel Construtores

Definição

Inicializa uma nova instância da classe TcpChannel.Initializes a new instance of the TcpChannel class.

Sobrecargas

TcpChannel()

Inicializa uma nova instância da classe TcpChannel, ativando apenas um canal de cliente e não um canal do servidor.Initializes a new instance of the TcpChannel class, activating only a client channel, and not a server channel.

TcpChannel(Int32)

Inicializa uma nova instância da classe TcpChannel com um canal de servidor que escuta na porta especificada.Initializes a new instance of the TcpChannel class with a server channel that listens on the specified port.

TcpChannel(IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider)

Inicializa uma nova instância da classe TcpChannel com as propriedades de configuração e os coletores especificados.Initializes a new instance of the TcpChannel class with the specified configuration properties and sinks.

TcpChannel()

Inicializa uma nova instância da classe TcpChannel, ativando apenas um canal de cliente e não um canal do servidor.Initializes a new instance of the TcpChannel class, activating only a client channel, and not a server channel.

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

Exemplos

O exemplo de código a seguir mostra como usar esse construtor.The following code example shows how to use this constructor.

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

Comentários

O construtor sem parâmetros inicializa todos os campos com seus valores padrão.The parameterless constructor initializes all fields to their default values. Se o construtor sem parâmetros for usado, o canal funcionará apenas como um canal de cliente e não escutará em nenhuma porta.If the parameterless constructor is used, the channel functions only as a client channel, and does not listen on any ports.

Aplica-se a

TcpChannel(Int32)

Inicializa uma nova instância da classe TcpChannel com um canal de servidor que escuta na porta especificada.Initializes a new instance of the TcpChannel class with a server channel that listens on the specified port.

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

A porta na qual o canal do servidor escuta.The port on which the server channel listens.

Exemplos

O exemplo de código a seguir demonstra como usar esse método.The following code example demonstrates using this method. Para solicitar que uma porta disponível seja atribuída dinamicamente, defina o port parâmetro como zero.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();
// 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()

Comentários

Para solicitar que o sistema remoto escolha uma porta aberta em seu nome, especifique a porta 0 (zero).To request that the remoting system choose an open port on your behalf, specify port 0 (zero). Isso criará uma TcpServerChannel instância para escutar solicitações na porta atribuída dinamicamente.This will create a TcpServerChannel instance to listen for requests on the dynamically assigned port. Isso normalmente é feito no cliente para garantir que o TcpServerChannel esteja escutando métodos de retorno de chamada.This is typically done on the client to make sure that a TcpServerChannel is listening for callback methods.

Se 0 for passado para o construtor, o TcpChannel será instanciado para usar uma porta livre.If 0 is passed to the constructor the TcpChannel is instantiated to use a free port.

Aplica-se a

TcpChannel(IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider)

Inicializa uma nova instância da classe TcpChannel com as propriedades de configuração e os coletores especificados.Initializes a new instance of the TcpChannel class with the specified configuration properties and sinks.

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

Uma coleção IDictionary que especifica valores para propriedades de configuração a ser usada pelos canais do cliente e do servidor.A IDictionary collection that specifies values for configuration properties to be used by the client and server channels.

clientSinkProvider
IClientChannelSinkProvider

A implementação IClientChannelSinkProvider a ser usada pelo canal de cliente.The IClientChannelSinkProvider implementation to be used by the client channel.

serverSinkProvider
IServerChannelSinkProvider

A implementação IServerChannelSinkProvider a ser usada pelo canal do servidor.The IServerChannelSinkProvider implementation to be used by the server channel.

Exceções

Uma propriedade de canal fornecida foi formatada incorretamente.A provided channel property was improperly formatted.

Exemplos

O exemplo de código a seguir mostra como usar esse construtor.The following code example shows how to use this 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);

Comentários

Para obter mais informações sobre as propriedades de configuração do canal, consulte canal e propriedades de configuração do formatador.For more information about channel configuration properties, see Channel and Formatter Configuration Properties.

Os coletores de canal fornecem um ponto de plug-in que permite o acesso às mensagens subjacentes que fluem pelo canal, bem como o fluxo usado pelo mecanismo de transporte para enviar mensagens a um objeto remoto.Channel sinks provide a plug-in point that allows access to the underlying messages flowing through the channel as well as the stream used by the transport mechanism to send messages to a remote object. Coletores de canal também são responsáveis por transportar mensagens entre o cliente e o servidor.Channel sinks are also responsible for transporting messages between the client and the server. Os coletores de canal são vinculados em uma cadeia e todas as mensagens de canal fluem por essa cadeia de coletores antes de a mensagem ser finalmente serializada e transportada.Channel sinks are linked together in a chain, and all channel messages flow through this chain of sinks before the message is finally serialized and transported. Se você não precisar da funcionalidade do coletor, defina clientSinkProvider os serverSinkProvider parâmetros e como null .If you do not require sink functionality, set the clientSinkProvider and serverSinkProvider parameters to null.

Aplica-se a