Monday, October 12, 2009

server

import java.rmi.Remote;
import java.rmi.RemoteException;


public interface inter extends Remote
{
double operate(double a, double b, int choice) throws RemoteException;
}

















import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
import java.rmi.server.UnicastRemoteObject;
import java.net.*;


public class server extends UnicastRemoteObject implements inter
{
public static Registry registry;


public double operate(double a, double b, int choice)
{

System.out.println("The first number : " + a);
System.out.println("The first number : " + b);

if(choice == 1)
{ System.out.println((a + b)); return (a + b); }
else if(choice == 2)
{ System.out.println((a - b)); return (a - b); }
else if(choice == 3)
{ System.out.println((a * b)); return (a * b); }
else
{ System.out.println((a / b)); return (a / b); }
}

server() throws RemoteException
{}

static public void main(String[] par)
{
try
{
server s = new server();
registry = LocateRegistry.createRegistry(3333);
registry.rebind("serverop", s);
}

catch(RemoteException e)
{
System.out.println(e);
System.exit(1);
}

}

}

1 comment:

  1. Well this is surely an interesting way to fill your log. Ask Peter what he does to have an email sent to me every time he updates his blog.

    ReplyDelete