void registerAndConnect ( SocketChannel sock , InetSocketAddress addr ) throws IOException { selectionKey = sock . register ( selector , SelectionKey . OP_CONNECT ) ; boolean immediateConnect = sock . connect ( addr ) ; if ( LOGGER . isTraceEnabled ( ) ) { LOGGER . trace ( "Connect to host=" + addr . getHostName ( ) + ", hostString=" + addr . getHostString ( ) + ", port=" + addr . getPort ( ) + ", all=" + addr . getAddress ( ) + ", local=" + sock . socket ( ) . getLocalSocketAddress ( ) ) ; } if ( immediateConnect ) { onConnectSucceeded ( ) ; } }
Register a SocketChannel and connect the remote address .