HttpChannel Math Server : Http Channel : Network C# Source Code


Custom Search

C# Source Code » Network » Http Channel »

 

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;
   }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Network
» Http Channel