@Override
    public void run() {
        byte[] buf = new byte[10000000];
        DatagramPacket p = new DatagramPacket(buf, buf.length);
        while (true) {
            try {
                //System.out.println("Waiting request");
                multiSocket.receive(p);// fica aguardando requisição. outra thread do peer permite a ele requisitar arquivos
                message = byteToMessage(p.getData());
                if (!message.getMemberIP().getHostAddress().equals(getLocalIP())) {

                    if (message.getTypeMsg().equals("discoveryMsg")) {
                        /*Verifica se tem no historico algum peer que contenha a musica*/
                        ArrayList<IMember> listMembers = new ArrayList<IMember>();
                        int i;
                        for (i = 0; i < peerLocal.musicList.size(); i++) {
                            if (peerLocal.musicList.get(i).equals(message.getFileName())) {
                                //System.out.println("Encontrada referëncia, enviar o rmi");
                                listMembers.add(peerLocal.peerList.get(i));
                            }
                        }
                        if (listMembers.size() > 0) {
                            IMember[] list = new IMember[listMembers.size()];
                            for (i = 0; i < listMembers.size(); i++) {
                                list[i] = listMembers.get(i);
                            }

                            try {
                                peer = (IMember) Naming.lookup("rmi://"+message.getMemberIP().getHostAddress()+":"+message.getMemberPort()+"/peer_"+(message.getMemberPort()));
                                peer.deliver(message.getFileName(), list);
                            } catch (NotBoundException | MalformedURLException | RemoteException ex) {
                                Logger.getLogger(PeerController.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        } else {
                            searchMusic();
                        }
                    } else { // HeartBeat message
                        
                    }
                }
            } catch (IOException ex) {
                Logger.getLogger(PeerController.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }