@Override
  public synchronized Object[] checkout()
          throws RemoteException {
    DatagramPacket pack;
    Socket recv;
    ServerSocket sock = null;
    byte[] bSend;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos;
    ObjectInputStream ois;
    Message msg = new Message();
    ArrayList<FileDescription> toRet = new ArrayList<FileDescription>();
    HashSet<String> files;
    FileDescription fileR;

    System.out.println("RMI: Received a checkout request");
    try {
      oos = new ObjectOutputStream(baos);
      oos.writeObject(msg);
      bSend = baos.toByteArray();
      pack = new DatagramPacket(bSend, bSend.length, InetAddress.getByName("225.0.0.5"), 41895);

      System.out.println("RMI: Getting the files set");
      files = FileParser.getTotalFiles(FileParser.parserFile("location.xml"));

      if (sock != null && !sock.isClosed()) {
        sock.close();
      }

      sock = new ServerSocket(10704);
      System.out.println("RMI: Sending request for files");
      _messages.send(pack);

      while (!files.isEmpty()) {
        System.out.println("RMI: Waiting to receive another file");
        recv = sock.accept();
        ois = new ObjectInputStream(recv.getInputStream());
        fileR = (FileDescription) ois.readObject();
        System.out.println("RMI: Received file " + fileR.getFileName());
        if (files.remove(fileR.getFileName())) {
          toRet.add(fileR);
        }
      }
    } catch (IOException ioe) {
      System.out.println(ioe.getMessage());
    } catch (ClassNotFoundException cnf) {
      System.out.println(cnf.getMessage());
    }

    System.out.println("RMI: Checkout built, returning");

    return toRet.toArray();
  }