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.
p | the DatagramPacket into which to place
the incoming data. |
IOException | if an I/O error occurs. | |
SocketTimeoutException | if setSoTimeout was previously called and the timeout has expired. | |
PortUnreachableException | may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown. | |
java.nio.channels.IllegalBlockingModeException
| if this socket has an associated channel, and the channel is in non-blocking mode. |
java.net.DatagramPacket, java.net.DatagramSocket
@revised 1.4
@spec JSR-51
Diagram: Socket