private void listen(byte[] listeningBuffer, int timeout) 
			throws IOException
	{
		IP myIP = new IP(InetAddress.getLocalHost());
		long ti = System.currentTimeMillis();
		long t = ti;
		/*
		 * Debugging
		 */
		Blacklist blacklist = new Blacklist();
		//blacklist.add(new IP(192,168,181,130));
		/*
		 * Debugging
		 */
		System.out.println(
				"[PacketManager] Listening for "
						+timeout+" ms...");
		netlock.lock();
		try {
			socket.setSoTimeout(timeout);
		}
		finally {
			netlock.unlock();
		}
		DatagramPacket packet = 
				new DatagramPacket(listeningBuffer,
						listeningBuffer.length);		
		ByteBuffer buffer;
		int numberOfPackets = 0;
		try {
			while(System.currentTimeMillis()-ti<timeout) {
				netlock.lock();
				try {
					socket.receive(packet);
				}
				finally {
					netlock.unlock();
				}
				/*
				 * Debugging
				 */
				if (!blacklist.contains(new IP(packet.getAddress()))) {
					/*
					 * Debugging
					 */

					if (!myIP.equals(new IP(packet.getAddress()))) {
						System.out.println(
								"[PacketManager] Packet received from "
										+packet.getAddress().getHostAddress());
						numberOfPackets++;
						buffer = ByteBuffer.allocate(
								packet.getData().length);
						buffer.put(packet.getData());
						buffer.flip(); // consult mode
						//Depends on the encoding !!
						if (buffer.array()[0]==MessageThread.lsaType
								&& lsaTable.isLatest(
										new IP(packet.getAddress()), 
										buffer)) {
							netlock.lock();
							try {
								System.out.println(
										"[PacketManager] LSA forwarded.");
								socket.send(packet);
							}
							finally {
								netlock.unlock();
							}
						}
						queue.add(buffer);
					}
					else
						System.out.println(
								"[PacketManager] Received from own address : "
										+ myIP);
					/*
					 * Debugging
					 */
				}
				/*
				 * Debugging
				 */

				t = System.currentTimeMillis();
				if (timeout-(t-ti)>10) {
					netlock.lock();
					try {
						socket.setSoTimeout((int)(timeout-(t-ti)));
					}
					finally {
						netlock.unlock();
					}	
				}
				else
					timeout = -1;
			}
		}
		catch (SocketTimeoutException e) {
		}
		System.out.println(
				"[PacketManager] Received "
						+numberOfPackets
						+" packets in "+timeout+" ms.");
	}