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:
parent
a262021334
commit
fd6ebf7be0
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue