TcpClientChannel Clase

Definición

En el caso de las llamadas remotas, implementa un canal de cliente que usa el protocolo TCP para transmitir mensajes.

public ref class TcpClientChannel : System::Runtime::Remoting::Channels::IChannelSender
public ref class TcpClientChannel : System::Runtime::Remoting::Channels::IChannelSender, System::Runtime::Remoting::Channels::ISecurableChannel
public class TcpClientChannel : System.Runtime.Remoting.Channels.IChannelSender
public class TcpClientChannel : System.Runtime.Remoting.Channels.IChannelSender, System.Runtime.Remoting.Channels.ISecurableChannel
type TcpClientChannel = class
    interface IChannelSender
    interface IChannel
type TcpClientChannel = class
    interface IChannelSender
    interface IChannel
    interface ISecurableChannel
Public Class TcpClientChannel
Implements IChannelSender
Public Class TcpClientChannel
Implements IChannelSender, ISecurableChannel
Herencia
TcpClientChannel
Implementaciones

Ejemplos

En el ejemplo de código siguiente se muestra el uso de la TcpClientChannel clase para llamar a un tipo remoto.

#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <Remotable.dll>

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;
int main()
{
   
   // Set up a client channel.
   TcpClientChannel^ clientChannel = gcnew TcpClientChannel;
   ChannelServices::RegisterChannel( clientChannel );
   
   // Show the name and priority of the channel.
   Console::WriteLine( "Channel Name: {0}", clientChannel->ChannelName );
   Console::WriteLine( "Channel Priority: {0}", clientChannel->ChannelPriority );
   
   // Obtain a proxy for a remote object.
   RemotingConfiguration::RegisterWellKnownClientType( Remotable::typeid, "tcp://localhost:9090/Remotable.rem" );
   
   // Call a method on the object.
   Remotable ^ remoteObject = gcnew Remotable;
   Console::WriteLine( remoteObject->GetCount() );
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class Client
{
    public static void Main()
    {

        // Set up a client channel.
        TcpClientChannel clientChannel = new TcpClientChannel();
        ChannelServices.RegisterChannel(clientChannel);

        // Show the name and priority of the channel.
        Console.WriteLine("Channel Name: {0}", clientChannel.ChannelName);
        Console.WriteLine("Channel Priority: {0}", clientChannel.ChannelPriority);

        // Obtain a proxy for a remote object.
        RemotingConfiguration.RegisterWellKnownClientType(
            typeof(Remotable), "tcp://localhost:9090/Remotable.rem"
        );

        // Call a method on the object.
        Remotable remoteObject = new Remotable();
        Console.WriteLine( remoteObject.GetCount() );
    }
}

El siguiente código define el tipo remoto llamado en el ejemplo anterior.

using namespace System;
using namespace System::Runtime::Remoting;

public ref class Remotable: public MarshalByRefObject
{
private:
   int callCount;

public:
   Remotable()
      : callCount( 0 )
   {}

   int GetCount()
   {
      callCount++;
      return (callCount);
   }
};
using System;
using System.Runtime.Remoting;

public class Remotable : MarshalByRefObject
{

    private int callCount = 0;

    public int GetCount()
    {
        callCount++;
        return(callCount);
    }
}

Comentarios

Importante

Llamar a métodos de esta clase con datos que no son de confianza es un riesgo de seguridad. Llame a los métodos de esta clase solo con datos de confianza. Para obtener más información, vea Validar todas las entradas.

Canales transporta mensajes a través de límites de comunicación remota (por ejemplo, equipos o dominios de aplicación). La TcpClientChannel clase transporta mensajes mediante el protocolo TCP.

La infraestructura remota de .NET Framework usa canales para transportar llamadas remotas. Cuando un cliente realiza una llamada a un objeto remoto, la llamada se serializa en un mensaje enviado por un canal de cliente y recibido por un canal de servidor. A continuación, se deserializa y se procesa. Los valores devueltos se transmiten por el canal del servidor y los recibe el canal de cliente.

Para realizar un procesamiento adicional de mensajes en el lado cliente, puede especificar una implementación de la interfaz a través de la IClientChannelSinkProvider cual se pasan todos los mensajes procesados por .TcpClientChannel

De forma predeterminada, la TcpClientChannel clase usa un formateador binario para serializar todos los mensajes.

Un TcpClientChannel objeto tiene propiedades de configuración asociadas que se pueden establecer en tiempo de ejecución en un archivo de configuración (invocando el método estático RemotingConfiguration.Configure ) o mediante programación (pasando una IDictionary colección al TcpClientChannel constructor). Para obtener una lista de estas propiedades de configuración, consulte la documentación de TcpClientChannel.

Constructores

Nombre Description
TcpClientChannel()

Inicializa una nueva instancia de la clase TcpClientChannel.

TcpClientChannel(IDictionary, IClientChannelSinkProvider)

Inicializa una nueva instancia de la TcpClientChannel clase con las propiedades de configuración y el receptor especificados.

TcpClientChannel(String, IClientChannelSinkProvider)

Inicializa una nueva instancia de la TcpClientChannel clase con el nombre y el receptor especificados.

Propiedades

Nombre Description
ChannelName

Obtiene el nombre del canal actual.

ChannelPriority

Obtiene la prioridad del canal actual.

IsSecured

Obtiene o establece un valor booleano que indica si el canal actual es seguro.

Métodos

Nombre Description
CreateMessageSink(String, Object, String)

Devuelve un receptor de mensajes de canal que entrega mensajes a la dirección URL o al objeto de datos del canal especificados.

Equals(Object)

Determina si el objeto especificado es igual al objeto actual.

(Heredado de Object)
GetHashCode()

Actúa como función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Objectactual.

(Heredado de Object)
Parse(String, String)

Extrae el URI del canal y el URI del objeto conocido remoto de la dirección URL especificada.

ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a