次の方法で共有


TcpChannel コンストラクタ (Int32)

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

名前空間: System.Runtime.Remoting.Channels.Tcp
アセンブリ: System.Runtime.Remoting (system.runtime.remoting.dll 内)

構文

'宣言
Public Sub New ( _
    port As Integer _
)
'使用
Dim port As Integer

Dim instance As New TcpChannel(port)
public TcpChannel (
    int port
)
public:
TcpChannel (
    int port
)
public TcpChannel (
    int port
)
public function TcpChannel (
    port : int
)

パラメータ

  • port
    サーバー チャネルの待機ポート。

解説

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

使用例

このメソッドを使用するコード例を次に示します。利用可能なポートが動的に割り当てられるように要求するには、port パラメータにゼロを設定します。

' 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()
// 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.
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();

.NET Framework のセキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「」を参照してください。

プラットフォーム

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

TcpChannel クラス
TcpChannel メンバ
System.Runtime.Remoting.Channels.Tcp 名前空間