TcpServerChannel クラス

定義

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メソッドを呼び出すことによって) またはプログラムによって (コンストラクターにTcpServerChannelコレクションを渡IDictionaryすことによって) 設定できます。 これらの構成プロパティの一覧については、「 チャネルとフォーマッタの構成プロパティ」を参照してください。

コンストラクター

TcpServerChannel(IDictionary, IServerChannelSinkProvider)

チャネル プロパティとシンクを指定して、TcpServerChannel クラスの新しいインスタンスを初期化します。

TcpServerChannel(IDictionary, IServerChannelSinkProvider, IAuthorizeRemotingConnection)

チャネル プロパティ、シンク、および承認プロバイダーを指定して、TcpServerChannel クラスの新しいインスタンスを初期化します。

TcpServerChannel(Int32)

指定したポートを待機する TcpServerChannel クラスの新しいインスタンスを初期化します。

TcpServerChannel(String, Int32)

指定した名前を持ち、指定したポートで待機する、TcpServerChannel クラスの新しいインスタンスを初期化します。

TcpServerChannel(String, Int32, IServerChannelSinkProvider)

指定した名前を持つ TcpServerChannel クラスの新しいインスタンスを初期化します。このインスタンスは、指定したポートで待機し、指定したシンクを使用します。

プロパティ

ChannelData

チャネル固有のデータを取得します。

ChannelName

現在のチャネルの名前を取得します。

ChannelPriority

現在のチャネルの優先順位を取得します。

IsSecured

現在のチャネルをセキュリティで保護しているかどうかを示すブール値を取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetChannelUri()

現在のチャネルの URI を返します。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
GetUrlsForUri(String)

指定した URI を持つオブジェクトのすべての URL のうち、現在の TcpChannel インスタンスでホストされている URL の配列を返します。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
Parse(String, String)

指定した URL からチャネル URI と既知のリモート オブジェクト URI を抽出します。

StartListening(Object)

StopListening(Object) メソッドを呼び出してチャネルのリッスンを停止した後、チャネルでのリッスンを始めるように現在のチャネルに指示します。

StopListening(Object)

現在のチャネルに対して、要求の待機を停止するように指示します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象