IpcChannel クラス
アセンブリ: System.Runtime.Remoting (system.runtime.remoting.dll 内)
構文
チャネルは、リモート呼び出しを転送するために .NET Framework のリモート処理インフラストラクチャによって使用されます。クライアントがリモート オブジェクトを呼び出すと、この呼び出しは、クライアント チャネルからサーバー チャネルに送信されるメッセージとしてシリアル化されます。メッセージの受信後、このメッセージが逆シリアル化され、処理されます。戻り値は、サーバー チャネルからクライアント チャネルに送信されます。
IpcChannel クラスは、IpcClientChannel クラスと IpcServerChannel クラスの機能を組み合わせた便利なクラスです。
IpcChannel を使用してリモート処理サーバーとそのクライアントを設定する方法を次のコード例に示します。この例は、次の 3 つの部分で構成されます。
using System; using System.Runtime.Remoting.Channels.Ipc; using System.Security.Permissions; public class Server { [SecurityPermission(SecurityAction.Demand)] public static void Main(string[] args) { // Create the server channel. IpcChannel serverChannel = new IpcChannel("localhost:9090"); // Register the server channel. System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel( serverChannel); // Show the name of the channel. Console.WriteLine("The name of the channel is {0}.", serverChannel.ChannelName); // Show the priority of the channel. Console.WriteLine("The priority of the channel is {0}.", serverChannel.ChannelPriority); // Show the URIs associated with the channel. System.Runtime.Remoting.Channels.ChannelDataStore channelData = (System.Runtime.Remoting.Channels.ChannelDataStore) serverChannel.ChannelData; foreach (string uri in channelData.ChannelUris) { Console.WriteLine("The channel URI is {0}.", uri); } // Expose an object for remote calls. System.Runtime.Remoting.RemotingConfiguration. RegisterWellKnownServiceType( typeof(RemoteObject), "RemoteObject.rem", System.Runtime.Remoting.WellKnownObjectMode.Singleton); // Parse the channel's URI. string[] urls = serverChannel.GetUrlsForUri("RemoteObject.rem"); if (urls.Length > 0) { string objectUrl = urls[0]; string objectUri; string channelUri = serverChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); Console.WriteLine("The object URL is {0}.", objectUrl); } // Wait for the user prompt. Console.WriteLine("Press ENTER to exit the server."); Console.ReadLine(); Console.WriteLine("The server is exiting."); } }
#using <System.dll> #using <System.Runtime.Remoting.dll> #using "common.dll" using namespace System; using namespace System::Runtime::Remoting::Channels::Ipc; void main() { // Create the server channel. IpcChannel^ serverChannel = gcnew IpcChannel( L"localhost:9090" ); // Register the server channel. System::Runtime::Remoting::Channels::ChannelServices::RegisterChannel( serverChannel ); // Show the name of the channel. Console::WriteLine( L"The name of the channel is {0}.", serverChannel->ChannelName ); // Show the priority of the channel. Console::WriteLine( L"The priority of the channel is {0}.", serverChannel->ChannelPriority ); // Show the URIs associated with the channel. System::Runtime::Remoting::Channels::ChannelDataStore^ channelData = (System::Runtime::Remoting::Channels::ChannelDataStore^)serverChannel->ChannelData; for each (String^ uri in channelData->ChannelUris) { Console::WriteLine("The channel URI is {0}.", uri); } // Expose an object for remote calls. System::Runtime::Remoting::RemotingConfiguration::RegisterWellKnownServiceType( RemoteObject::typeid,L"RemoteObject.rem", System::Runtime::Remoting::WellKnownObjectMode::Singleton); // Parse the channel's URI. array<String^>^ urls = serverChannel->GetUrlsForUri( L"RemoteObject.rem" ); if ( urls->Length > 0 ) { String^ objectUrl = urls[ 0 ]; String^ objectUri; String^ channelUri = serverChannel->Parse( objectUrl, objectUri ); Console::WriteLine( L"The object URI is {0}.", objectUri ); Console::WriteLine( L"The channel URI is {0}.", channelUri ); Console::WriteLine( L"The object URL is {0}.", objectUrl ); } // Wait for the user prompt. Console::WriteLine( L"Press ENTER to exit the server." ); Console::ReadLine(); Console::WriteLine( L"The server is exiting." ); }
using System; using System.Runtime.Remoting.Channels.Ipc; using System.Security.Permissions; public class Client { [SecurityPermission(SecurityAction.Demand)] public static void Main(string[] args) { // Create the channel. IpcChannel channel = new IpcChannel(); // Register the channel. System.Runtime.Remoting.Channels.ChannelServices. RegisterChannel(channel); // Register as client for remote object. System.Runtime.Remoting.WellKnownClientTypeEntry remoteType = new System.Runtime.Remoting.WellKnownClientTypeEntry( typeof(RemoteObject), "ipc://localhost:9090/RemoteObject.rem"); System.Runtime.Remoting.RemotingConfiguration. RegisterWellKnownClientType(remoteType); // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = channel.CreateMessageSink( "ipc://localhost:9090/RemoteObject.rem", null , out objectUri); Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } // Create an instance of the remote object. RemoteObject service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times." , service.GetCount()); } }
#using <System.dll> #using <System.Runtime.Remoting.dll> #using "common.dll" using namespace System; using namespace System::Runtime::Remoting::Channels::Ipc; void main() { // Create the channel. IpcChannel^ channel = gcnew IpcChannel; // Register the channel. System::Runtime::Remoting::Channels::ChannelServices::RegisterChannel(channel); // Register as client for remote object. System::Runtime::Remoting::WellKnownClientTypeEntry^ remoteType = gcnew System::Runtime::Remoting::WellKnownClientTypeEntry( RemoteObject::typeid,L"ipc://localhost:9090/RemoteObject.rem" ); System::Runtime::Remoting::RemotingConfiguration::RegisterWellKnownClientType(remoteType); // Create a message sink. String^ objectUri; System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = channel->CreateMessageSink( L"ipc://localhost:9090/RemoteObject.rem", nullptr, objectUri ); Console::WriteLine( L"The URI of the message sink is {0}.", objectUri ); if ( messageSink != nullptr ) { Console::WriteLine( L"The type of the message sink is {0}.", messageSink->GetType() ); } // Create an instance of the remote object. RemoteObject^ service = gcnew RemoteObject; // Invoke a method on the remote object. Console::WriteLine( L"The client is invoking the remote object." ); Console::WriteLine( L"The remote object has been called {0} times.", service->GetCount() ); }
System.Runtime.Remoting.Channels.Ipc.IpcChannel
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
IpcChannel コンストラクタ ()
アセンブリ: System.Runtime.Remoting (system.runtime.remoting.dll 内)
構文
使用例
.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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
IpcChannel コンストラクタ (IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider)
アセンブリ: System.Runtime.Remoting (system.runtime.remoting.dll 内)
構文
Public Sub New ( _ properties As IDictionary, _ clientSinkProvider As IClientChannelSinkProvider, _ serverSinkProvider As IServerChannelSinkProvider _ )
Dim properties As IDictionary Dim clientSinkProvider As IClientChannelSinkProvider Dim serverSinkProvider As IServerChannelSinkProvider Dim instance As New IpcChannel(properties, clientSinkProvider, serverSinkProvider)
public IpcChannel ( IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider )
public: IpcChannel ( IDictionary^ properties, IClientChannelSinkProvider^ clientSinkProvider, IServerChannelSinkProvider^ serverSinkProvider )
public IpcChannel ( IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider )
public function IpcChannel ( properties : IDictionary, clientSinkProvider : IClientChannelSinkProvider, serverSinkProvider : IServerChannelSinkProvider )
チャネル構成プロパティの詳細については、「チャネルおよびフォーマッタの構成プロパティ」を参照してください。
チャネル シンクは、そのチャネルを流れている基になるメッセージにアクセスできるようにするプラグイン ポイント、およびリモート オブジェクトにメッセージを送信するために転送機構が使用するストリームを提供します。チャネル シンクは、クライアントとサーバー間でのメッセージの転送も行います。チャネル シンクはチェインで互いにリンクされ、すべてのチャネル メッセージはこのシンクのチェインを流れ、メッセージは最終的にシリアル化されて転送されます。シンク機能が不要な場合は、clientSinkProvider パラメータおよび serverSinkProvider パラメータを null 参照 (Visual Basic では Nothing) に設定します。
このコンストラクタを使用するコードの例を次に示します。このコード例は、IpcChannel クラスのトピックで取り上げているコード例の一部分です。
// Create the server channel. System.Collections.IDictionary properties = new System.Collections.Hashtable(); properties["name"] = "ipc"; properties["priority"] = "20"; properties["portName"] = "localhost:9090"; IpcChannel serverChannel = new IpcChannel(properties, null, null);
// Create the server channel. System::Collections::IDictionary^ properties = gcnew System::Collections::Hashtable; properties->default[ L"name" ] = L"ipc"; properties->default[ L"priority" ] = L"20"; properties->default[ L"portName" ] = L"localhost:9090"; IpcChannel^ serverChannel = gcnew IpcChannel( properties,nullptr,nullptr );
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
IpcChannel コンストラクタ
オーバーロードの一覧
名前 | 説明 |
---|---|
IpcChannel () | サーバー チャネルを除き、クライアント チャネルだけをアクティブにして、IpcChannel クラスの新しいインスタンスを初期化します。 |
IpcChannel (String) | 指定した IPC ポートで待機するサーバー チャネルを使用して IpcChannel クラスの新しいインスタンスを初期化します。 |
IpcChannel (IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider) | 構成プロパティとシンクを指定して、IpcChannel クラスの新しいインスタンスを初期化します。 |
IpcChannel コンストラクタ (String)
アセンブリ: System.Runtime.Remoting (system.runtime.remoting.dll 内)
構文
使用例
.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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
IpcChannel プロパティ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
ChannelData | チャネル固有のデータを取得します。 | |
ChannelName | 現在のチャネルの名前を取得します。 | |
ChannelPriority | 現在のチャネルの優先順位を取得します。 | |
IsSecured | 現在のチャネルをセキュリティで保護しているかどうかを示すブール値を取得または設定します。 |
IpcChannel メソッド
パブリック メソッド
名前 | 説明 | |
---|---|---|
CreateMessageSink | 指定した URL またはチャネル データ オブジェクトにメッセージを配信するチャネル メッセージ シンクを返します。 | |
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) | |
GetUrlsForUri | 指定した URI を持つオブジェクトのすべての URL のうち、現在の IpcChannel でホストされている URL の配列を返します。 | |
Parse | 指定した URL からチャネル URI と既知のリモート オブジェクト URI を抽出します。 | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) | |
StartListening | 現在のチャネルに対して、要求の待機を開始するように指示します。 | |
StopListening | 現在のチャネルに対して、要求の待機を停止するように指示します。 | |
ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
IpcChannel メンバ
IPC プロトコルを使用してメッセージを送信するチャネル実装を提供します。
IpcChannel データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
ChannelData | チャネル固有のデータを取得します。 | |
ChannelName | 現在のチャネルの名前を取得します。 | |
ChannelPriority | 現在のチャネルの優先順位を取得します。 | |
IsSecured | 現在のチャネルをセキュリティで保護しているかどうかを示すブール値を取得または設定します。 |
名前 | 説明 | |
---|---|---|
CreateMessageSink | 指定した URL またはチャネル データ オブジェクトにメッセージを配信するチャネル メッセージ シンクを返します。 | |
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) | |
GetUrlsForUri | 指定した URI を持つオブジェクトのすべての URL のうち、現在の IpcChannel でホストされている URL の配列を返します。 | |
Parse | 指定した URL からチャネル URI と既知のリモート オブジェクト URI を抽出します。 | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) | |
StartListening | 現在のチャネルに対して、要求の待機を開始するように指示します。 | |
StopListening | 現在のチャネルに対して、要求の待機を停止するように指示します。 | |
ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
- IPC channelのページへのリンク