TcpClientChannel 클래스

정의

원격 호출의 경우 TCP 프로토콜을 사용하여 메시지를 전송하는 클라이언트 채널을 구현합니다.

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
상속
TcpClientChannel
구현

예제

다음 코드 예제에서는 클래스를 TcpClientChannel 사용하여 원격 형식을 호출하는 방법을 보여줍니다.

#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() );
    }
}

위의 예제에서 호출된 원격 형식은 다음 코드로 정의됩니다.

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);
    }
}

설명

Important

신뢰할 수 없는 데이터를 사용하여 이 클래스에서 메서드를 호출하는 것은 보안 위험입니다. 신뢰할 수 있는 데이터로만 이 클래스의 메서드를 호출합니다. 자세한 내용은 모든 입력 유효성 검사참조하세요.

채널은 원격 경계(예: 컴퓨터 또는 애플리케이션 도메인)를 통해 메시지를 전송합니다. 클래스는 TcpClientChannel TCP 프로토콜을 사용하여 메시지를 전송합니다.

채널은 .NET Framework 원격 인프라에서 원격 호출을 전송하는 데 사용됩니다. 클라이언트가 원격 개체를 호출하면 클라이언트 채널에서 보내고 서버 채널에서 수신하는 메시지로 호출이 직렬화됩니다. 그런 다음 역직렬화되고 처리됩니다. 반환된 값은 서버 채널에서 전송되고 클라이언트 채널에서 수신됩니다.

클라이언트 쪽에서 메시지의 추가 처리를 수행하려면 처리된 모든 메시지가 전달되는 인터페이스의 IClientChannelSinkProvider 구현을 TcpClientChannel 지정할 수 있습니다.

기본적으로 클래스는 TcpClientChannel 이진 포맷터를 사용하여 모든 메시지를 직렬화합니다.

TcpClientChannel 개체에는 구성 파일(정적 RemotingConfiguration.Configure 메서드를 호출하여) 또는 프로그래밍 방식으로(생성자에 컬렉션을 전달하여) 런타임에 설정할 수 있는 IDictionary 연결된 구성 속성이 TcpClientChannel 있습니다. 이러한 구성 속성 목록은 에 대한 TcpClientChannel설명서를 참조하세요.

생성자

Name Description
TcpClientChannel()

TcpClientChannel 클래스의 새 인스턴스를 초기화합니다.

TcpClientChannel(IDictionary, IClientChannelSinkProvider)

지정된 구성 속성 및 싱크를 TcpClientChannel 사용하여 클래스의 새 인스턴스를 초기화합니다.

TcpClientChannel(String, IClientChannelSinkProvider)

지정된 이름과 싱크를 사용하여 클래스의 TcpClientChannel 새 인스턴스를 초기화합니다.

속성

Name Description
ChannelName

현재 채널의 이름을 가져옵니다.

ChannelPriority

현재 채널의 우선 순위를 가져옵니다.

IsSecured

현재 채널이 안전한지 여부를 나타내는 부울 값을 가져오거나 설정합니다.

메서드

Name Description
CreateMessageSink(String, Object, String)

지정된 URL 또는 채널 데이터 개체에 메시지를 전달하는 채널 메시지 싱크를 반환합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Parse(String, String)

지정된 URL에서 채널 URI 및 잘 알려진 원격 개체 URI를 추출합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상