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 datagramDatagrams in the channel's socket receive buffer , which have not been received before invoking this method, may be discarded. The channel's 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 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. Once connected, no further security checks are performed for datagrams received from, or sent to, the given remote address. Care should be taken to ensure that a connected datagram channel is not shared with untrusted code.
This method may be invoked at any time. It will not have any effect onIf another thread has already initiated a read or write operations that are already in progress at the moment that itoperation upon this channel, then an invocation of this method will block until any such operation is invokedcomplete. 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.
-
Parameters:
-
remote - The remote address to which this channel is to be connected
-
Returns:
- This datagram channel
-
Throws:
-
AlreadyConnectedException - If this channel is already 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
-
UnresolvedAddressException - If the given remote address is not fully resolved
-
UnsupportedAddressTypeException - If the type of the given remote address is not supported
-
SecurityException - If a security manager has been installed and it does not permit access to the given remote address, or if unbound, the security manager checkListen method denies the operation
-
IOException - If some other I/O error occurs
|
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 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.
-
Parameters:
-
remote - The remote address to which this channel is to be connected
-
Returns:
- This datagram channel
-
Throws:
-
AlreadyConnectedException - If this channel is already 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
-
UnresolvedAddressException - If the given remote address is not fully resolved
-
UnsupportedAddressTypeException - If the type of the given remote address is not supported
-
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
|
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. Datagrams in the channel's socket receive buffer , which have not been received before invoking this method, may be discarded. The channel's 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 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. Once connected, no further security checks are performed for datagrams received from, or sent to, the given remote address. Care should be taken to ensure that a connected datagram channel is not shared with untrusted code.
This method may be invoked at any time. If another thread has already initiated a read or write operation upon this channel, then an invocation of this method will block until any such operation is complete. 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.
-
Parameters:
-
remote - The remote address to which this channel is to be connected
-
Returns:
- This datagram channel
-
Throws:
-
AlreadyConnectedException - If this channel is already 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
-
UnresolvedAddressException - If the given remote address is not fully resolved
-
UnsupportedAddressTypeException - If the type of the given remote address is not supported
-
SecurityException - If a security manager has been installed and it does not permit access to the given remote address, or if unbound, the security manager checkListen method denies the operation
-
IOException - If some other I/O error occurs
|
|