TcpChannel コンストラクター

定義

TcpChannel クラスの新しいインスタンスを初期化します。

オーバーロード

名前 説明
TcpChannel()

サーバー チャネルではなく、クライアント チャネルのみをアクティブ化して、 TcpChannel クラスの新しいインスタンスを初期化します。

TcpChannel(Int32)

指定したポートでリッスンするサーバー チャネルを使用して、 TcpChannel クラスの新しいインスタンスを初期化します。

TcpChannel(IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider)

指定した構成プロパティとシンクを使用して、 TcpChannel クラスの新しいインスタンスを初期化します。

TcpChannel()

サーバー チャネルではなく、クライアント チャネルのみをアクティブ化して、 TcpChannel クラスの新しいインスタンスを初期化します。

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

次のコード例は、このコンストラクターの使用方法を示しています。

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

注釈

パラメーターなしのコンストラクターは、すべてのフィールドを既定値に初期化します。 パラメーターなしのコンストラクターが使用されている場合、チャネルはクライアント チャネルとしてのみ機能し、ポートをリッスンしません。

適用対象

TcpChannel(Int32)

指定したポートでリッスンするサーバー チャネルを使用して、 TcpChannel クラスの新しいインスタンスを初期化します。

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)

パラメーター

port
Int32

サーバー チャネルがリッスンするポート。

次のコード例では、このメソッドの使用方法を示します。 使用可能なポートを動的に割り当てることを要求するには、 port パラメーターを 0 に設定します。

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

注釈

リモート処理システムが自分の代わりに開いているポートを選択するように要求するには、ポート 0 (ゼロ) を指定します。 これにより、動的に割り当てられたポートで要求をリッスンする TcpServerChannel インスタンスが作成されます。 これは通常、 TcpServerChannel がコールバック メソッドをリッスンしていることを確認するためにクライアントで行われます。

コンストラクターに 0 が渡された場合、 TcpChannel は空きポートを使用するようにインスタンス化されます。

適用対象

TcpChannel(IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider)

指定した構成プロパティとシンクを使用して、 TcpChannel クラスの新しいインスタンスを初期化します。

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)

パラメーター

properties
IDictionary

クライアントおよびサーバー チャネルで使用する構成プロパティの値を指定する IDictionary コレクション。

clientSinkProvider
IClientChannelSinkProvider

クライアント チャネルによって使用される IClientChannelSinkProvider 実装。

serverSinkProvider
IServerChannelSinkProvider

サーバー チャネルによって使用される IServerChannelSinkProvider 実装。

例外

指定されたチャネル プロパティの形式が正しくありません。

次のコード例は、このコンストラクターの使用方法を示しています。

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

注釈

チャネル シンクには、チャネルを通過する基になるメッセージへのアクセスと、リモート オブジェクトにメッセージを送信するためにトランスポート メカニズムで使用されるストリームへのアクセスを許可するプラグイン ポイントが用意されています。 チャネル シンクは、クライアントとサーバーの間でメッセージを転送する役割も担います。 チャネル シンクはチェーン内でリンクされ、メッセージが最終的にシリアル化されて転送される前に、すべてのチャネル メッセージがこのシンク チェーンを通過します。 シンク機能が不要な場合は、 clientSinkProvider パラメーターと serverSinkProvider パラメーターを nullに設定します。

適用対象