public Process(String name, int pid, int n) {

    this.name = name;
    this.port = Utils.REGISTRAR_PORT + pid;

    this.host = "UNKNOWN";
    try {
      this.host = (InetAddress.getLocalHost()).getHostName();

    } catch (UnknownHostException e) {
      String msg = String.format("Error: getHostName() failed at %s.", this.getInfo());
      System.err.println(msg);
      System.err.println(e.getMessage());
      System.exit(1);
    }

    this.pid = pid;
    this.n = n;

    random = new Random();

    /* Accepts connections from one of Registrar's worker threads */
    new Thread(new Listener(this)).start();
    /* Connect to registrar */
    socket = connect();
    init();
    Utils.out(pid, "Connected.");
  }
 public boolean registeR() {
   String payload;
   Message m;
   boolean result;
   payload = String.format("%s:%s:%d", name, host, port);
   m = new Message(pid, 0, "NULL", payload);
   result = await(m.pack());
   if (result) Utils.out(pid, "Registered.");
   return result;
 }
  public synchronized void receive(Message m) {

    Utils.out(pid, m.toString()); /* The default action. */
  }