HttpChannel Math Server
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
public class MathServer
{
public static int Main()
{
HttpChannel chan = new HttpChannel(9050);
ChannelServices.RegisterChannel(chan);
RemotingConfiguration.RegisterWellKnownServiceType(
Type.GetType("MathClass, MathClass"), "MyMathServer",
WellKnownObjectMode.SingleCall);
Console.WriteLine("Hit <enter> to exit...");
Console.ReadLine();
return 0;
}
}
public class MathClass : MarshalByRefObject
{
public int Add(int a, int b)
{
int c = a + b;
return c;
}
public int Subtract(int a, int b)
{
int c = a - b;
return c;
}
public int Multiply(int a, int b)
{
int c = a * b;
return c;
}
public int Divide(int a, int b)
{
int c;
if (b != 0)
c = a / b;
else
c = 0;
return c;
}
}
Related examples in the same category