Receives a datagram packet from this socket. When this method returns, the
DatagramPacket
'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.
This method blocks until a datagram is received. The length
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.
If there is a security manager, a packet cannot be received if the security manager's checkAccept
method does not allow it.
@param p the DatagramPacket
into which to placethe incoming data.
@exception IOException if an I/O error occurs.
@exception SocketTimeoutException if setSoTimeout was previously calledand the timeout has expired.
@exception PortUnreachableException may be thrown if the socket is connectedto a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.
@exception java.nio.channels.IllegalBlockingModeException if this socket has an associated channel, and the channel is in non-blocking mode.
@see java.net.DatagramPacket
@see java.net.DatagramSocket
@revised 1.4
@spec JSR-51