From the website:-http://www.developer.com/net/net/article.php/3522466/Improved-NET-Remoting-Part-2-Secure-TCP.htm
Create a Server to Expose the Remotable Object via TCP
To create a server object that will act as a listener to accepts remote object requests, you create an instance of the channel and then register it for use by clients on a specific port. You can register the service as WellKnownObjectMode.SingleCall, which results in a new instance of the object for each client, or as WellKnownObjectMode.Singleton, which results in one instance of the object used for all clients.
For this example, create a server listener. Because the service needs to be bound to an available port, choose a port that you know to be unused on your computer. (The example code uses 8080.) To see a list of the used ports on your computer, open a command prompt and issue the command "netstat -a". It may produce a long list, so make sure the command prompt buffer sizes are set to allow scrolling. Compile the class to make sure you have everything correct.
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace CodeGuru.RemotingSample
{
/// <remarks>
/// Sample server to demonstrate the use of secure .NET Remoting.
/// </remarks>
public class SampleRemotingServer
{
public static void Main()
{
// Set up the configuration parameters through a dictionary
IDictionary properties = new Hashtable();
properties.Add("port", 8080);
properties.Add("secure", true);
properties.Add("impersonate", true);
// Create an instance of a channel
TcpServerChannel serverChannel =
new TcpServerChannel(properties, null);
ChannelServices.RegisterChannel(serverChannel);
// Register as an available service with the name HelloWorld
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(SampleObject),
"HelloWorld.rem",
WellKnownObjectMode.Singleton );
Console.WriteLine("Listening on {0}",
serverChannel.GetChannelUri());
Console.WriteLine("Press the enter key to exit...");
Console.ReadLine();
}
}
}
Add a reference in your project to System.Runtime.Remoting; otherwise, the TcpChannel and other related classes will not be found. In addition, add a reference to the project containing the SampleObject. Otherwise, the code will not compile because it won't know how to find a reference to SampleObject.
To secure the communication programmatically, you need to configure the server connection. Notice how the example code passes parameter information in through a Dictionary. You can configure a number of additional parameters (Find more parameters in the VS 2005 Beta Docs on MSDN.) The parameters you will use on the server side for this example are as follows:
port: Specifies the port number on which the channel will listen.
secure: Indicates whether or not the channel is to be secured. (When secured, the channel can require user credentials, as well as encrypt and sign the communication. If the TcpServerChannel is secure, the TcpClientChannel must also be secure. Otherwise, no connection is made.)
impersonate: Indicates whether or not the server should impersonate the client.