Connects this channel's socket.
The channel's socket is configured so that it only receives datagrams from, and sends datagrams to, the given remote peer address. Once connected, datagrams may not be received from or sent to any other address. A datagram socket remains connected until it is explicitly disconnected or until it is closed.
This method performs exactly the same security checks as the connect
method of the java.net.DatagramSocket
class. That is, if a security manager has been
installed then this method verifies that its checkAccept
and checkConnect
methods permit
datagrams to be received from and sent to, respectively, the given
remote address.
This method may be invoked at any time. It will not have any effect
on read or write operations that are already in progress at the moment
that it is invoked. If this channel's socket is not bound then this method
will first cause the socket to be bound to an address that is assigned
automatically, as if invoking the bind
method with a
parameter of null
.
remote
| The remote address to which this channel is to be connected |
ClosedChannelException
| If this channel is closed | |
AsynchronousCloseException
| If another thread closes this channel while the connect operation is in progress | |
ClosedByInterruptException
| If another thread interrupts the current thread while the connect operation is in progress, thereby closing the channel and setting the current thread's interrupt status | |
SecurityException
| If a security manager has been installed and it does not permit access to the given remote address | |
IOException
| If some other I/O error occurs |
Diagram: SocketChannel