本文整理汇总了C#中System.Runtime.Remoting.Channels.Tcp.TcpChannel.CreateMessageSink方法的典型用法代码示例。如果您正苦于以下问题:C# TcpChannel.CreateMessageSink方法的具体用法?C# TcpChannel.CreateMessageSink怎么用?C# TcpChannel.CreateMessageSink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Remoting.Channels.Tcp.TcpChannel
的用法示例。
在下文中一共展示了TcpChannel.CreateMessageSink方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
public override void Open()
{
TcpChannel channel = new TcpChannel();
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
string host = string.Format("tcp://{0}:{1}", Address, Port);
System.Runtime.Remoting.WellKnownClientTypeEntry remoteType =
new System.Runtime.Remoting.WellKnownClientTypeEntry(
typeof(FARemoteObject), host + "/RemoteObject.rem");
System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownClientType(remoteType);
string objectUri;
System.Runtime.Remoting.Messaging.IMessageSink messageSink = channel.CreateMessageSink(
host + "/RemoteObject.rem", null,
out objectUri);
if (messageSink == null)
{
throw new Exception(string.Format("{0} Open fail. fail create message sink", Name));
}
_service = new FARemoteObject();
try
{
_service.ConnectTest(); // 최초 접속을 시도한다.
}
catch
{
// 접속에 실패해도 넘어간다. 이후 SetData(), GetData() 가 호출될 때 접속이 되는지 확인한다.
}
}