Apply initial socket parameters prior to bind operation

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1596951 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2014-05-22 19:45:59 +00:00
parent a262021334
commit fd6ebf7be0
1 changed files with 7 additions and 7 deletions

View File

@ -114,7 +114,14 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection
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(true, linger);
}
conn.bind(sock);
final InetSocketAddress remoteAddress = new InetSocketAddress(address, port);
@ -122,15 +129,8 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection
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(true, linger);
}
conn.bind(sock);
if (this.log.isDebugEnabled()) {
this.log.debug("Connection established " + conn);