public synchronized void prepareSocket ( ) throws IOException { if ( ! prepared ) { final long fd = getFileDescriptor ( ) ; if ( fd == INVALID_SOCKET ) { throw new AsyncException ( AsyncProperties . aio_handle_unavailable ) ; } channelIdentifier = provider . prepare2 ( fd , asyncChannelGroup . getCompletionPort ( ) ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "prepareSocket - socket prepared, fd = " + fd + " channel id: " + channelIdentifier + " " + ", local: " + channel . socket ( ) . getLocalSocketAddress ( ) + ", remote: " + channel . socket ( ) . getRemoteSocketAddress ( ) ) ; } long callid = 0 ; // init to zero, reset when IO requested readIOCB = ( CompletionKey ) AsyncLibrary . completionKeyPool . get ( ) ; if ( readIOCB != null ) { // initialize the IOCB from the pool readIOCB . initializePoolEntry ( channelIdentifier , callid ) ; writeIOCB = ( CompletionKey ) AsyncLibrary . completionKeyPool . get ( ) ; if ( writeIOCB != null ) { // initialize the IOCB from the pool writeIOCB . initializePoolEntry ( channelIdentifier , callid ) ; } else { writeIOCB = new CompletionKey ( channelIdentifier , callid , defaultBufferCount ) ; } } else { readIOCB = new CompletionKey ( channelIdentifier , callid , defaultBufferCount ) ; writeIOCB = new CompletionKey ( channelIdentifier , callid , defaultBufferCount ) ; } provider . initializeIOCB ( readIOCB ) ; provider . initializeIOCB ( writeIOCB ) ; prepared = true ; } }
Perform initialization steps for this new connection .