protected Socket createSocketFromFactory ( SocketFactory factory , String host , int port ) throws IOException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Connecting to " + host + " on port " + port + " (timeout: " + CONTEXT . getConfig ( ) . getConnectTimeout ( ) + " ms) using factory " + factory . getClass ( ) . getName ( ) ) ; } SocketAddress address = new InetSocketAddress ( host , port ) ; Socket socket = factory . createSocket ( ) ; socket . connect ( address , CONTEXT . getConfig ( ) . getConnectTimeout ( ) ) ; // Set amount of time to wait on socket read before timing out socket . setSoTimeout ( CONTEXT . getConfig ( ) . getSocketTimeout ( ) ) ; socket . setKeepAlive ( true ) ; return socket ; }
Creates a new connected socket to a given host and port from a provided Socket Factory .