private void connectCommon ( Object _udpRequestContextObject ) throws IOException { String localAddress = "*" ; int localPort = 0 ; Map < Object , Object > vcStateMap = getVirtualConnection ( ) . getStateMap ( ) ; if ( vcStateMap != null ) { // // Size of the buffer the channel should use to read. // String value = ( String ) vcStateMap . get ( UDPConfigConstants . CHANNEL_RCV_BUFF_SIZE ) ; if ( value != null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , UDPConfigConstants . CHANNEL_RCV_BUFF_SIZE + " " + value ) ; } cfg . setChannelReceiveBufferSize ( Integer . parseInt ( value ) ) ; } // // Receive buffer size. // value = ( String ) vcStateMap . get ( UDPConfigConstants . RCV_BUFF_SIZE ) ; if ( value != null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , UDPConfigConstants . RCV_BUFF_SIZE + " " + value ) ; } cfg . setReceiveBufferSize ( Integer . parseInt ( value ) ) ; } // // Send buffer size // value = ( String ) vcStateMap . get ( UDPConfigConstants . SEND_BUFF_SIZE ) ; if ( value != null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , UDPConfigConstants . SEND_BUFF_SIZE + " " + value ) ; } cfg . setSendBufferSize ( Integer . parseInt ( value ) ) ; } } // // Allow for this to be null. If the requestContext is null, then just // allow The NetworkLayer to find the port to listen on. // if ( _udpRequestContextObject != null ) { final UDPRequestContext udpRequestContext = ( UDPRequestContext ) _udpRequestContextObject ; final InetSocketAddress addr = udpRequestContext . getLocalAddress ( ) ; localAddress = addr . getAddress ( ) . getHostAddress ( ) ; localPort = addr . getPort ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "connect with local address: " + localAddress + " local port: " + localPort ) ; } } udpNetworkLayer = new UDPNetworkLayer ( udpChannel , workQueueMgr , localAddress , localPort ) ; udpNetworkLayer . initDatagramSocket ( getVirtualConnection ( ) ) ; udpNetworkLayer . setConnLink ( this ) ; }
Common connect logic between sync and async connect requests .