using System;
namespace Server
{
// class that is accessible to remote clients
public class Hello : MarshalByRefObject
{
public String GetMessage()
{
return "Hello From Server At Srikanth Technologies.";
}
}
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace Server
{
class HelloServer
{
static void Main(string[] args)
{
TcpChannel channel = new TcpChannel(9999); // port no. 9999
// Register channel
ChannelServices.RegisterChannel(channel,false);
// Register as an available service with the name hello
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(Hello),
"hello",
WellKnownObjectMode.SingleCall
);
System.Console.WriteLine("Press the enter key to exit...");
System.Console.ReadLine();
} // end of main
} // end of class
} // end of namespace
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace Client
{
class HelloClient
{
public static void Main(string[] args)
{
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel,false);
// Get an instance of the remote object
Server.Hello obj = ( Server.Hello)Activator.GetObject(
typeof(Server.Hello),
"tcp://localhost:9999/Hello"
);
// Use the object
Console.WriteLine(obj.GetMessage());
}
}
}