private void managePeerConnection() throws Exception{	        
		//Send/ receive handshake
        if(!manageHandshake()){
        	//handshake failed - quit connection to this peer.
        	return;
        }
        
        //After handshake, instantiates a message sender;
        this.messageSender = new MessageSender(peer, out);
        Thread thread = new Thread(this.messageSender);
        thread.start();
        
        //Keep connection with peer up sending/receiving messages until the user initiates the shutdown sequence
		while(!manager.stopThreads){
        	try{
        		if(!peer.amConnected()){
        			disposeCurrPiece();
        			closeConnections();
        			return;
        		}
        		processMessage(Message.decode(in), peer);
        		Thread.sleep(10);
        	} catch (EOFException eofe){
        		System.err.println("EOFException from peer " + this.peer + "... disconnecting from peer.");
        		disposeCurrPiece();
        		closeConnections();
        		return;
        	}
        }
        
        //close streams/ Socket
        System.out.println("Closing streams and socket for Peer: " + peer.toString());
        closeConnections();
    }