Thursday, 4 October 2012

C# Remoting via TCP Channel

Use TCP protocol to transmit messages.

http://msdn.microsoft.com/en-us/library/system.runtime.remoting.channels.tcp.tcpchannel.aspx
------------------------------------------------------------------------
namespace Server
{
    class Program
    {
        static void Main(string[] args)
        {
            TcpChannel tcpChannel = new TcpChannel(7777);

            ChannelServices.RegisterChannel(tcpChannel, false);
            ServerQueue queue = new ServerQueue();
            RemotingServices.Marshal(queue, "ServerQueue");

            RemotingConfiguration.ApplicationName = "MyRemoteService";
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerQueue), "ServerQueue", WellKnownObjectMode.Singleton);
        }
    }
}




No comments:

Post a Comment