be silently discarded. Invoking send() sends the content
be silently discarded. Invoking send() sends the content of the given ByteBuffer object, from its current position to its limit, to the destination address and port described by the given SocketAddress object. If the DatagramChannel object is in blocking mode, the invoking thread may sleep until the datagram can be queued for transmission. If the channel is nonblocking, the return value will be either the number of bytes in the byte buffer or 0. Sending datagrams is an all-or-nothing proposition. If the transmit queue does not have sufficient room to hold the entire datagram, then nothing at all is sent. If a security manager is installed, its checkConnect() method will be called on every invocation of send() or receive() to validate the destination address, unless the channel is in a connected state (discussed later in this section). Note that datagram protocols are inherently unreliable; they make no delivery guarantees. A nonzero return value from send() does not indicate that the datagram arrived at its destination, only that it was successfully queued to the local networking layer for transmission. Additionally, transport protocols along the way may fragment the datagram. Ethernet, for example, cannot transport packets larger than about 1,500 bytes. If your datagram is large, it runs the risk of being broken into pieces, multiplying the chances of packet loss in transit. The datagram will be reassembled at the destination, and the receiver won’t see the fragments, but if any fragments fail to arrive in a timely manner, the entire datagram will be discarded. The DatagramChannel has a connect() method: public abstract class DatagramChannel extends AbstractSelectableChannel implements ByteChannel, ScatteringByteChannel, GatheringByteChannel { // This is a partial API listing public abstract DatagramChannel connect (SocketAddress remote) throws IOException; public abstract boolean isConnected(); public abstract DatagramChannel disconnect() throws IOException; } The connection semantics of a DatagramChannel are different for datagram sockets than they are for stream sockets. Sometimes it’s desirable to restrict the datagram conversation to two parties. Placing a DatagramChannel into a connected state causes datagrams to be ignored from any source address other than the one to which the channel is “connected.” This can be helpful because the unwanted packets will be dropped by the networking layer, relieving your code of the effort required to receive, check, and discard them. 113
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services