Get a datagram from this channel.
This method transfers the datagram from the channel into the target byte buffer and return the address of the datagram, if the datagram is available or will be available as this channel is in blocking mode. This method returns null
if the datagram is not available now and the channel is in non-blocking mode. The transfer start at the current position of the buffer, and the residual part of the datagram will be ignored if there is no efficient remaining in the buffer to store the datagram.
This method can be called at any moment, and will block if there is another thread started a read operation on the channel.
This method just execute the same security checks as the receive method of the DatagramSocket
class.
@param target The byte buffer to store the received datagram.
@return Address of the datagram if the transfer is performed, or null ifthe channel is in non-blocking mode and the datagrama are unavailable.
@throws ClosedChannelException If the channel is already closed.
@throws AsynchronousCloseException If the channel is closed by another thread while this method is in operation.
@throws ClosedByInterruptException If another thread interrupts the calling thread while the operation is in progress. The calling thread will have the interrupt state set, and the channel will be closed.
@throws SecurityException If there is a security manager, and the address is not permitted to access.
@throws IOException Some other IO error occurred.