/** * Receives a datagram packet from this socket. When this method returns, the * <tt>DatagramPacket</tt>'s buffer is filled with the data received. The datagram packet also * contains the sender's IP address, and the port number on the sender's machine. * * <p>This method blocks until a datagram is received. The <tt>length</tt> field of the datagram * packet object contains the length of the received message. If the message is longer than the * packet's length, the message is truncated. * * @param p the <tt>DatagramPacket</tt> into which to place the incoming data * @throws IOException if an I/O error occurs * @see DatagramSocket#receive(DatagramPacket) */ @Override public void receive(DatagramPacket p) throws IOException { synchronized (inReceiveSyncRoot) { inReceive++; } try { super.receive(p); } finally { synchronized (inReceiveSyncRoot) { inReceive--; inReceiveSyncRoot.notifyAll(); } } }