TcpServerChannel 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
TCP 프로토콜을 사용하여 메시지를 전송하는 원격 호출에 대한 서버 채널을 구현합니다.
public ref class TcpServerChannel : System::Runtime::Remoting::Channels::IChannelReceiver
public ref class TcpServerChannel : System::Runtime::Remoting::Channels::IChannelReceiver, System::Runtime::Remoting::Channels::ISecurableChannel
public class TcpServerChannel : System.Runtime.Remoting.Channels.IChannelReceiver
public class TcpServerChannel : System.Runtime.Remoting.Channels.IChannelReceiver, System.Runtime.Remoting.Channels.ISecurableChannel
type TcpServerChannel = class
interface IChannelReceiver
interface IChannel
type TcpServerChannel = class
interface IChannelReceiver
interface IChannel
interface ISecurableChannel
Public Class TcpServerChannel
Implements IChannelReceiver
Public Class TcpServerChannel
Implements IChannelReceiver, ISecurableChannel
- 상속
-
TcpServerChannel
- 구현
예제
다음 코드 예제에서는 원격 사용 가능한 형식의 사용을 보여줍니다.
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);
}
}
다음 코드 예제에서는 클래스를 사용하여 TcpServerChannel 원격 가능 형식을 노출하는 방법을 보여줍니다.
#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 server channel.
TcpServerChannel^ serverChannel = gcnew TcpServerChannel( 9090 );
ChannelServices::RegisterChannel( serverChannel );
// Expose an object for remote calls.
RemotingConfiguration::RegisterWellKnownServiceType( Remotable::typeid, "Remotable.rem", WellKnownObjectMode::Singleton );
// Show the name and priority of the channel.
Console::WriteLine( "Channel Name: {0}", serverChannel->ChannelName );
Console::WriteLine( "Channel Priority: {0}", serverChannel->ChannelPriority );
// Show the URIs associated with the channel.
ChannelDataStore^ data = dynamic_cast<ChannelDataStore^>(serverChannel->ChannelData);
System::Collections::IEnumerator^ myEnum = data->ChannelUris->GetEnumerator();
while ( myEnum->MoveNext() )
{
String^ uri = safe_cast<String^>(myEnum->Current);
Console::WriteLine( uri );
}
// Wait for method calls.
Console::WriteLine( "Listening..." );
Console::ReadLine();
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
public class Server
{
public static void Main()
{
// Set up a server channel.
TcpServerChannel serverChannel = new TcpServerChannel(9090);
ChannelServices.RegisterChannel(serverChannel);
// Expose an object for remote calls.
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(Remotable), "Remotable.rem", WellKnownObjectMode.Singleton
);
// Show the name and priority of the channel.
Console.WriteLine("Channel Name: {0}", serverChannel.ChannelName);
Console.WriteLine("Channel Priority: {0}", serverChannel.ChannelPriority);
// Show the URIs associated with the channel.
ChannelDataStore data = (ChannelDataStore) serverChannel.ChannelData;
foreach (string uri in data.ChannelUris)
{
Console.WriteLine(uri);
}
// Wait for method calls.
Console.WriteLine("Listening...");
Console.ReadLine();
}
}
설명
중요합니다
신뢰할 수 없는 데이터를 사용하여 이 클래스에서 메서드를 호출하는 것은 보안 위험입니다. 신뢰할 수 있는 데이터로만 이 클래스의 메서드를 호출합니다. 자세한 내용은 모든 입력 유효성 검사참조하세요.
채널은 원격 경계(예: 컴퓨터 또는 애플리케이션 도메인)를 통해 메시지를 전송합니다. 클래스는 TcpServerChannel TCP 프로토콜을 사용하여 메시지를 전송합니다.
채널은 .NET Framework 원격 인프라에서 원격 호출을 전송하는 데 사용됩니다. 클라이언트가 원격 개체를 호출하면 클라이언트 채널에서 보내고 서버 채널에서 수신하는 메시지로 호출이 직렬화됩니다. 그런 다음 역직렬화되고 처리됩니다. 반환된 값은 서버 채널에서 전송되고 클라이언트 채널에서 수신됩니다.
서버 쪽에서 메시지의 추가 처리를 수행하려면 인스턴스에서 처리된 모든 메시지가 전달되는 인터페이스의 IServerChannelSinkProvider 구현을 TcpServerChannel 지정할 수 있습니다.
인스턴스는 이 TcpServerChannel 진 또는 SOAP 형식으로 직렬화된 메시지를 허용합니다.
TcpServerChannel 개체에는 구성 파일(정적 RemotingConfiguration.Configure 메서드를 호출하여) 또는 프로그래밍 방식으로(생성자에 컬렉션을 전달하여) 런타임에 설정할 수 있는 IDictionary 연결된 구성 속성이 TcpServerChannel 있습니다.
생성자
| Name | Description |
|---|---|
| TcpServerChannel(IDictionary, IServerChannelSinkProvider, IAuthorizeRemotingConnection) |
지정된 채널 속성, 싱크 및 권한 부여 공급자를 TcpServerChannel 사용하여 클래스의 새 인스턴스를 초기화합니다. |
| TcpServerChannel(IDictionary, IServerChannelSinkProvider) |
지정된 채널 속성 및 싱크를 TcpServerChannel 사용하여 클래스의 새 인스턴스를 초기화합니다. |
| TcpServerChannel(Int32) |
지정된 포트에서 수신 대기하는 클래스의 TcpServerChannel 새 인스턴스를 초기화합니다. |
| TcpServerChannel(String, Int32, IServerChannelSinkProvider) |
지정된 포트에서 수신 대기하고 지정된 싱크를 사용하는 지정된 이름을 사용하여 클래스의 TcpServerChannel 새 인스턴스를 초기화합니다. |
| TcpServerChannel(String, Int32) |
지정된 이름과 지정된 포트에서 TcpServerChannel 수신 대기하는 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| ChannelData |
채널별 데이터를 가져옵니다. |
| ChannelName |
현재 채널의 이름을 가져옵니다. |
| ChannelPriority |
현재 채널의 우선 순위를 가져옵니다. |
| IsSecured |
현재 채널이 안전한지 여부를 나타내는 부울 값을 가져오거나 설정합니다. |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetChannelUri() |
현재 채널의 URI를 반환합니다. |
| GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| GetUrlsForUri(String) |
현재 TcpChannel 인스턴스에서 호스트되는 지정된 URI를 사용하여 개체에 대한 모든 URL의 배열을 반환합니다. |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| Parse(String, String) |
지정된 URL에서 채널 URI 및 잘 알려진 원격 개체 URI를 추출합니다. |
| StartListening(Object) |
채널에서 수신을 중지하도록 메서드가 호출된 후 StopListening(Object) 채널에서 수신 대기를 시작하도록 현재 채널에 지시합니다. |
| StopListening(Object) |
현재 채널에 요청 수신 대기를 중지하도록 지시합니다. |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |