Csharp/C Sharp by API/System.Runtime.Remoting.Channels/ChannelServices — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 15:11, 26 мая 2010
ChannelServices.RegisterChannel
<source lang="csharp">
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; }
}
</source>