one more try to fix the connection problem

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4556 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent a3dadcd89b
commit d87d295c68

@ -396,11 +396,14 @@ public final class httpc {
this.initTime = System.currentTimeMillis();
this.lastIO = System.currentTimeMillis();
this.socket.setKeepAlive(false);
// setting socket timeout and keep alive behaviour
// set socket timeout and keep alive behavior
assert timeout >= 1000;
this.socket.setSoTimeout(timeout); // waiting time for read
this.socket.setTcpNoDelay(true); // no accumulation until buffer is full
this.socket.setSoLinger(true, timeout); // wait for all data being written on close()
// get the connection
this.socket.connect(address, timeout);
this.socket.setSoTimeout(timeout); // waiting time for read
if (incomingByteCountAccounting != null) {
this.clientInputByteCount = new httpdByteCountInputStream(this.socket.getInputStream(),incomingByteCountAccounting);

@ -410,7 +410,17 @@ public final class serverCore extends serverAbstractThread implements serverThre
if ((this.denyHost == null) || (this.denyHost.get(cIP) == null)) {
// setting the timeout properly
assert this.timeout >= 1000;
controlSocket.setSoTimeout(this.timeout);
// keep-alive: if set to true, the server frequently sends keep-alive packets to the client which the client must respond to
// we set this to false to prevent that a missing ack from the client forces the server to close the connection
controlSocket.setKeepAlive(false);
// disable Nagle's algorithm (waiting for more data until packet is full)
controlSocket.setTcpNoDelay(true);
// set a non-zero linger, that means that a socket.close() blocks until all data is written
controlSocket.setSoLinger(true, this.timeout);
// create session
Session connection = new Session(sessionThreadGroup, controlSocket, this.timeout);

Loading…
Cancel
Save