IpcServerChannel 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为远程调用实现使用 IPC 系统传输消息的服务器信道。
public ref class IpcServerChannel : System::Runtime::Remoting::Channels::IChannelReceiver, System::Runtime::Remoting::Channels::ISecurableChannelpublic class IpcServerChannel : System.Runtime.Remoting.Channels.IChannelReceiver, System.Runtime.Remoting.Channels.ISecurableChanneltype IpcServerChannel = class
    interface IChannelReceiver
    interface IChannel
    interface ISecurableChannelPublic Class IpcServerChannel
Implements IChannelReceiver, ISecurableChannel- 继承
- 
				IpcServerChannel
- 实现
示例
下面的代码示例演示如何使用 IpcServerChannel 类。
#using <system.runtime.remoting.dll>
#using <System.dll>
#using <Counter.dll>
using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Ipc;
public ref class IpcServer
{
public:
   void IpcServerTest()
   {
      // Create and register an IPC channel
      IpcServerChannel^ serverChannel = gcnew IpcServerChannel( L"remote" );
      ChannelServices::RegisterChannel( serverChannel );
      // Expose an object
      RemotingConfiguration::RegisterWellKnownServiceType( Counter::typeid, L"counter", WellKnownObjectMode::Singleton );
      
      // Wait for calls
      Console::WriteLine( L"Listening on {0}", serverChannel->GetChannelUri() );
      Console::ReadLine();
   }
};
int main()
{
   IpcServer^ is = gcnew IpcServer;
   is->IpcServerTest();
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
public class IpcServer
{
    public static void Main ()
    {
        // Create and register an IPC channel
        IpcServerChannel serverChannel = new IpcServerChannel("remote");
        ChannelServices.RegisterChannel(serverChannel);
        // Expose an object
        RemotingConfiguration.RegisterWellKnownServiceType( typeof(Counter), "counter", WellKnownObjectMode.Singleton );
        // Wait for calls
        Console.WriteLine("Listening on {0}", serverChannel.GetChannelUri());
        Console.ReadLine();
    }
}
上述代码用于公开以下远程对象。
using namespace System;
public ref class Counter: public MarshalByRefObject
{
private:
   int count;
public:
   Counter()
   {
      count = 0;
   }
   property int Count 
   {
      int get()
      {
         return (count)++;
      }
   }
};
using System;
public class Counter : MarshalByRefObject {
  private int count = 0;
  public int Count { get {
    return(count++);
  } }
}
有关远程使用此对象的客户端的示例,请参阅 IpcClientChannel。
注解
重要
使用不受信任的数据调用此类中的方法存在安全风险。 仅使用受信任的数据调用此类中的方法。 有关详细信息,请参阅 验证所有输入。
.NET Framework远程处理基础结构使用通道来传输远程呼叫。 当客户端调用远程对象时,调用将序列化为由客户端通道发送并由服务器通道接收的消息。 收到消息后,将对其进行反序列化和处理。 任何返回的值都由服务器通道传输,并由客户端通道接收。
类 IpcServerChannel 使用 Windows 进程间通信 (IPC) 系统在同一台计算机上的应用程序域之间传输消息。 在同一计算机上的应用程序域之间进行通信时,IPC 通道比 TCP 或 HTTP 通道快得多。
若要在服务器端执行消息的其他处理,请指定 接口的实现, IServerChannelSinkProvider 通过该接口传递实例处理 IpcServerChannel 的所有消息。
实例 IpcServerChannel 接受以二进制或 SOAP 格式序列化的消息。
对象IpcServerChannel具有关联的配置属性,可以在运行时通过调用静态RemotingConfiguration.Configure方法) (配置文件中设置这些属性,或通过将集合传递到IDictionaryIpcServerChannel构造函数) 以编程方式 (。 有关这些配置属性的列表,请参阅构造函数的文档 IpcServerChannel 。
注意
在 参数中exclusiveAddressUseproperties将 属性设置为 false 时,可以为同一命名管道注册多个IpcServerChannel对象。 在这种情况下,请求可以转到任何已注册的通道。 仅当还使用 ALC 时,此设置才被视为安全设置。
构造函数
| IpcServerChannel(IDictionary, IServerChannelSinkProvider) | 使用指定的信道属性和接收器初始化 IpcServerChannel 类的新实例。 | 
| IpcServerChannel(IDictionary, IServerChannelSinkProvider, CommonSecurityDescriptor) | 使用指定的信道属性、接收器和安全说明符初始化 IpcServerChannel 类的新实例。 | 
| IpcServerChannel(String) | 用指定的 IPC 端口名初始化 IpcServerChannel 类的新实例。 | 
| IpcServerChannel(String, String) | 用指定的信道名称和 IPC 端口名称初始化 IpcServerChannel 类的新实例。 | 
| IpcServerChannel(String, String, IServerChannelSinkProvider) | 使用指定的信道名称、IPC 端口名称和接收器初始化 IpcServerChannel 类的新实例。 | 
属性
| ChannelData | 获取通道特定的数据。 | 
| ChannelName | 获取当前信道的名称。 | 
| ChannelPriority | 获取当前信道的优先级。 | 
| IsSecured | 获取或设置一个布尔值,该值指示当前信道是否安全。 | 
方法
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetChannelUri() | 返回当前信道的 URI。 | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| GetUrlsForUri(String) | 返回具有指定 URI 的对象的所有 URL 的数组,该对象承载在当前的 IpcChannel 实例上。 | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| Parse(String, String) | 从指定 URL 提取信道 URI 和远程已知对象 URI。 | 
| StartListening(Object) | 指示当前信道开始侦听请求。 | 
| StopListening(Object) | 指示当前信道停止侦听请求。 | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |