You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2014/05/22 21:45:39 UTC

svn commit: r1596950 - /httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java

Author: olegk
Date: Thu May 22 19:45:38 2014
New Revision: 1596950

URL: http://svn.apache.org/r1596950
Log:
Apply initial socket parameters prior to bind operation

Modified:
    httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java?rev=1596950&r1=1596949&r2=1596950&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java Thu May 22 19:45:38 2014
@@ -105,7 +105,14 @@ class HttpClientConnectionOperator {
             final boolean last = i == addresses.length - 1;
 
             Socket sock = sf.createSocket(context);
+            sock.setSoTimeout(socketConfig.getSoTimeout());
             sock.setReuseAddress(socketConfig.isSoReuseAddress());
+            sock.setTcpNoDelay(socketConfig.isTcpNoDelay());
+            sock.setKeepAlive(socketConfig.isSoKeepAlive());
+            final int linger = socketConfig.getSoLinger();
+            if (linger >= 0) {
+                sock.setSoLinger(linger > 0, linger);
+            }
             conn.bind(sock);
 
             final InetSocketAddress remoteAddress = new InetSocketAddress(address, port);
@@ -113,15 +120,8 @@ class HttpClientConnectionOperator {
                 this.log.debug("Connecting to " + remoteAddress);
             }
             try {
-                sock.setSoTimeout(socketConfig.getSoTimeout());
                 sock = sf.connectSocket(
                         connectTimeout, sock, host, remoteAddress, localAddress, context);
-                sock.setTcpNoDelay(socketConfig.isTcpNoDelay());
-                sock.setKeepAlive(socketConfig.isSoKeepAlive());
-                final int linger = socketConfig.getSoLinger();
-                if (linger >= 0) {
-                    sock.setSoLinger(linger > 0, linger);
-                }
                 conn.bind(sock);
                 if (this.log.isDebugEnabled()) {
                     this.log.debug("Connection established " + conn);