Connect the socket to remote address.
If the channel is blocking, this method will suspend before connection finished or an I/O exception. If the channel is non-blocking, this method will return true
if the connection is finished at once or return false
and the connection must wait finishConnect
to finished otherwise.
This method can be called at any moment, and can block other read and write operations while connecting.
This method just execute the same security checks as the connect method of the Socket
class.
@param address The address to be connected.
@return
true
if connection is finished,
false
otherwise.
@throws AlreadyConnectedException If the channel is connected already.
@throws ConnectionPendingException A non-blocking connecting is doing on this channel.
@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 UnresolvedAddressException If the address is not resolved.
@throws UnsupportedAddressTypeException If the address type is not supported.
@throws SecurityException If there is a security manager, and the address is not permitted to access.
@throws IOException Some other IO error occurred.