public static void main(String[] args) 
           throws InterruptedException, RemoteException, IOException, NotBoundException{

    
    String hostrmi = null;
    int portrmi = 0;
    int id = 0;
    InetAddress ip = null;
  
     //parametro de entrada ip rmiregistry
    // recibir por linea de comando mi ip y mi id
     
    if (!((0 < args.length) && (args.length < 4))) {
	    System.out.print("Parametros incorrectos: ");
	    System.out.println("VersionControlServer <hostNamermi> <ID> <IP>");
	    return;
    }

    try {
      
	    hostrmi = args[0];
	    portrmi = 40619;
      id = Integer.parseInt(args[1]);
      ip = InetAddress.getByName(args[2]);
      
    }
    catch (Exception e) {
	    System.out.println("java.lang.Exception");
	    System.out.println(e);
      //System.exit(1);
    }
     
    InetAddress group = InetAddress.getByName("225.0.0.5");
     
    MulticastSocket s = new MulticastSocket(10602);
    
    MulticastSocket p = new MulticastSocket(41895);
    
    System.out.println("Uniendome al grupo");
     
    s.joinGroup(group);
    p.joinGroup(group);
    
    System.out.println("Me uni al grupo");
    
    VersionControlServer v = new VersionControlServer(null, id, hostrmi, portrmi,
            new VersionControlImpl(p, "location.xml", 3));
   
    Thread election = new ServerElection(s, v);
    election.start();
    
    while(v.coordId == -1)
      Thread.sleep(6000);
    System.out.println("Por aqui pase;");
    VersionControl vci = (VersionControl) Naming.lookup("rmi://" + hostrmi + ":" + portrmi
            + "/VCS");
     
    /* mando un mensaje con mi id diciendo q me uno a la red */
    vci.requestEntry(id, ip);
    
    System.out.println("Actualizando los archivos");
    
  Object[] files = vci.updateServer(id);
    boolean b = true;
    for(Object fdo: files){
      FileDescription fd = (FileDescription) fdo;
      if(b){
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(fd.getData()));
        try {
          FileParser.updateXMLFile("location.xml", (Document)ois.readObject());
        } catch (ClassNotFoundException ex) {
          System.out.println(ex.getMessage());
        }
        b = false;
        continue;
      }
      fd.writeData();
    }
    
    HashMap<Integer, InetAddress> dns = new HashMap<Integer, InetAddress>();
    
    for(Element serv : FileParser.serverList(FileParser.parserFile("location.xml")))
      dns.put(Integer.parseInt(FileParser.getValueOfServer(serv, "id")),
              InetAddress.getByName(FileParser.getValueOfServer(serv, "ip"))
              );

    v.setDns(dns);
    System.out.println("Ya tengo DNS!");
    Thread listenMessages = new ServerCommunication(p, v);
    
    listenMessages.start();
    
    System.out.println("se crearon los hilos, espero por el join");
    election.join();
    listenMessages.join();
   }