// Collection of code snippets by Arne VajhÃ¸j 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package test.client;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;

import test.common.MyClient;
import test.common.MyServer;

// client hoved program
public class MyClientMain {
   public static void main(String[] args) {
      try {
         // enable security
         System.setSecurityManager(new RMISecurityManager());
         // lookup remote server
         MyServer srv = (MyServer) Naming.lookup("rmi://" + args[0] + ":60000/MyServer");
         // create client object og registrer på server
         MyClient cli = new MyClientImpl();
         srv.register(cli);
         // test call
         srv.send("a");
         srv.send("bb");
         srv.send("ccc");
         // afregistrer
         srv.unregister(cli);
         // afslut
         System.exit(0);
      } catch (MalformedURLException e) {
         e.printStackTrace();
      } catch (RemoteException e) {
         e.printStackTrace();
      } catch (NotBoundException e) {
         e.printStackTrace();
      }
   }
}
