本文整理汇总了C#中System.Runtime.Remoting.Channels.Tcp.TcpClientChannel类的典型用法代码示例。如果您正苦于以下问题:C# TcpClientChannel类的具体用法?C# TcpClientChannel怎么用?C# TcpClientChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TcpClientChannel类属于System.Runtime.Remoting.Channels.Tcp命名空间,在下文中一共展示了TcpClientChannel类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Security.Permissions;
public class Client
{
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Main()
{
// Set up a client channel.
TcpClientChannel clientChannel = new TcpClientChannel();
ChannelServices.RegisterChannel(clientChannel);
// Show the name and priority of the channel.
Console.WriteLine("Channel Name: {0}", clientChannel.ChannelName);
Console.WriteLine("Channel Priority: {0}", clientChannel.ChannelPriority);
// Obtain a proxy for a remote object.
RemotingConfiguration.RegisterWellKnownClientType(
typeof(Remotable), "tcp://localhost:9090/Remotable.rem"
);
// Call a method on the object.
Remotable remoteObject = new Remotable();
Console.WriteLine( remoteObject.GetCount() );
}
}
示例2: GetCount
//引入命名空间
using System;
using System.Runtime.Remoting;
public class Remotable : MarshalByRefObject
{
private int callCount = 0;
public int GetCount()
{
callCount++;
return(callCount);
}
}