New Math Client : Http Channel : Network C# Source Code


Custom Search

C# Source Code » Network » Http Channel »

 

New Math Client








    


using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

public class NewMathClient
{
   public static int Main(string[] argv)
   {
      HttpChannel chan = new HttpChannel();
      ChannelServices.RegisterChannel(chan);
      MathClass obj = new MathClass();
      if (obj == null) 
         System.Console.WriteLine("Could not locate server");
      else
      {
         int a = Convert.ToInt32(argv[0]);
         int b = Convert.ToInt32(argv[1]);
         int c = obj.Add(a, b);
         Console.WriteLine("a + b = {0}", c);
         c = obj.Subtract(a, b);
         Console.WriteLine("a - b = {0}", c);
         c = obj.Multiply(a, b);
         Console.WriteLine("a * b = {0}", c);
         c = obj.Divide(a, b);
         Console.WriteLine("a / b = {0}", c);
      }
      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