@Override public Socket connectSocket(final Socket sock, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException { checkArgument(remoteAddress != null, "Remote address may not be null"); checkArgument(params != null, "HTTP parameters may not be null"); Socket socket = sock != null ? sock : new Socket(); if (localAddress != null) { socket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); socket.bind(localAddress); } socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params)); socket.connect(remoteAddress, HttpConnectionParams.getConnectionTimeout(params)); if (socket instanceof SSLSocket) { return socket; } return getSSLContext().getSocketFactory() .createSocket(socket, remoteAddress.getHostName(), remoteAddress.getPort(), true); }
@Override public Socket connectSocket(final Socket sock, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException { checkArgument(remoteAddress != null, "Remote address may not be null"); checkArgument(params != null, "HTTP parameters may not be null"); Socket socket = sock != null ? sock : new Socket(); if (localAddress != null) { socket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); socket.bind(localAddress); } socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params)); socket.connect(remoteAddress, HttpConnectionParams.getConnectionTimeout(params)); if (socket instanceof SSLSocket) { return socket; } return getSSLContext().getSocketFactory() .createSocket(socket, remoteAddress.getHostName(), remoteAddress.getPort(), true); }
sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); sock.bind(localAddress);
/** * @since 4.1 */ public Socket connectSocket( final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException, ConnectTimeoutException { Args.notNull(remoteAddress, "Remote address"); Args.notNull(params, "HTTP parameters"); Socket sock = socket; if (sock == null) { sock = createSocket(); } if (localAddress != null) { sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); sock.bind(localAddress); } final int connTimeout = HttpConnectionParams.getConnectionTimeout(params); final int soTimeout = HttpConnectionParams.getSoTimeout(params); try { sock.setSoTimeout(soTimeout); sock.connect(remoteAddress, connTimeout); } catch (final SocketTimeoutException ex) { throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out"); } return sock; }
/** * @since 4.1 */ @Override public Socket connectSocket( final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException, ConnectTimeoutException { Args.notNull(remoteAddress, "Remote address"); Args.notNull(params, "HTTP parameters"); Socket sock = socket; if (sock == null) { sock = createSocket(); } if (localAddress != null) { sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); sock.bind(localAddress); } final int connTimeout = HttpConnectionParams.getConnectionTimeout(params); final int soTimeout = HttpConnectionParams.getSoTimeout(params); try { sock.setSoTimeout(soTimeout); sock.connect(remoteAddress, connTimeout); } catch (final SocketTimeoutException ex) { throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out"); } return sock; }
/** * @since 4.1 */ public Socket connectSocket( final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException, ConnectTimeoutException { Args.notNull(remoteAddress, "Remote address"); Args.notNull(params, "HTTP parameters"); Socket sock = socket; if (sock == null) { sock = createSocket(); } if (localAddress != null) { sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); sock.bind(localAddress); } final int connTimeout = HttpConnectionParams.getConnectionTimeout(params); final int soTimeout = HttpConnectionParams.getSoTimeout(params); try { sock.setSoTimeout(soTimeout); sock.connect(remoteAddress, connTimeout); } catch (final SocketTimeoutException ex) { throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out"); } return sock; }
/** * @since 4.1 */ @Override public Socket connectSocket( final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException, ConnectTimeoutException { Args.notNull(remoteAddress, "Remote address"); Args.notNull(params, "HTTP parameters"); Socket sock = socket; if (sock == null) { sock = createSocket(); } if (localAddress != null) { sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); sock.bind(localAddress); } final int connTimeout = HttpConnectionParams.getConnectionTimeout(params); final int soTimeout = HttpConnectionParams.getSoTimeout(params); try { sock.setSoTimeout(soTimeout); sock.connect(remoteAddress, connTimeout); } catch (final SocketTimeoutException ex) { throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out"); } return sock; }
private void performConnection(final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws SocketException, IOException { try { socket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); socket.bind(localAddress); int connectionTimeout = HttpConnectionParams.getConnectionTimeout(params); int socketTimeout = HttpConnectionParams.getSoTimeout(params); socket.connect(remoteAddress, connectionTimeout); socket.setSoTimeout(socketTimeout); } catch (SocketException e) { Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, ECFHttpClientSecureProtocolSocketFactory.class, "performConnection", e); //$NON-NLS-1$ fireEvent(this.socketConnectListener, new SocketClosedEvent(source, socket, socket)); Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, ECFHttpClientSecureProtocolSocketFactory.class, "performConnection", e); //$NON-NLS-1$ throw e; } catch (IOException e) { Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, ECFHttpClientSecureProtocolSocketFactory.class, "performConnection", e); //$NON-NLS-1$ fireEvent(this.socketConnectListener, new SocketClosedEvent(source, socket, socket)); Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, ECFHttpClientSecureProtocolSocketFactory.class, "performConnection", e); //$NON-NLS-1$ throw e; } }
private void performConnection(final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws SocketException, IOException { try { socket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); if (localAddress != null) { // only explicitly bind if a local address is actually provided (bug 444377) socket.bind(localAddress); } int connectionTimeout = HttpConnectionParams.getConnectionTimeout(params); int socketTimeout = HttpConnectionParams.getSoTimeout(params); socket.connect(remoteAddress, connectionTimeout); socket.setSoTimeout(socketTimeout); } catch (SocketException e) { Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, ECFHttpClientSecureProtocolSocketFactory.class, "performConnection", e); //$NON-NLS-1$ fireEvent(this.socketConnectListener, new SocketClosedEvent(source, socket, socket)); Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, ECFHttpClientSecureProtocolSocketFactory.class, "performConnection", e); //$NON-NLS-1$ throw e; } catch (IOException e) { Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, ECFHttpClientSecureProtocolSocketFactory.class, "performConnection", e); //$NON-NLS-1$ fireEvent(this.socketConnectListener, new SocketClosedEvent(source, socket, socket)); Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, ECFHttpClientSecureProtocolSocketFactory.class, "performConnection", e); //$NON-NLS-1$ throw e; } }
public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params) throws IOException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); SSLSocket sslsocket = (SSLSocket) ((sock != null) ? sock : createSocket(params)); if (localAddress != null) { sslsocket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); sslsocket.bind(localAddress); } try { sslsocket.setSoTimeout(soTimeout); sslsocket.connect(remoteAddress, connTimeout ); } catch (SocketTimeoutException ex) { throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out"); } return sslsocket; }