Sends out a datagram by the channel.
The precondition of sending is that whether the channel is in blocking mode and enough byte buffer space will be available, or the channel is in non-blocking mode and byte buffer space is enough. The transfer action is just like a regular write operation.
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 send method of the DatagramSocket
class.
@param source The byte buffer with the datagram to be sent.
@param address The address to be sent.
@return The number of sent bytes. If this method is called, it returnsthe number of bytes that remaining in the byte buffer. If the channel is in non-blocking mode and no enough space for the datagram in the buffer, it may returns zero.
@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.