forked from I2P_Developers/i2p.i2p
SAM: Set keepalive on sockets (ticket #1573)
Also on both sides of I2CP. BOB already does it.
This commit is contained in:
@ -46,6 +46,7 @@ class SAMHandlerFactory {
|
||||
try {
|
||||
Socket sock = s.socket();
|
||||
sock.setSoTimeout(HELLO_TIMEOUT);
|
||||
sock.setKeepAlive(true);
|
||||
String line = DataHelper.readLine(sock.getInputStream());
|
||||
sock.setSoTimeout(0);
|
||||
if (line == null) {
|
||||
|
@ -263,6 +263,7 @@ class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handler.Sessi
|
||||
|
||||
// build pipes between both sockets
|
||||
try {
|
||||
clientServerSock.socket().setKeepAlive(true);
|
||||
if (this.verbose)
|
||||
SAMv3Handler.notifyStreamIncomingConnection(
|
||||
clientServerSock, i2ps.getPeerDestination());
|
||||
|
@ -488,6 +488,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
|
||||
try {
|
||||
I2PSSLSocketFactory fact = new I2PSSLSocketFactory(_context, false, "certificates/i2cp");
|
||||
_socket = fact.createSocket(_hostname, _portNum);
|
||||
_socket.setKeepAlive(true);
|
||||
} catch (GeneralSecurityException gse) {
|
||||
IOException ioe = new IOException("SSL Fail");
|
||||
ioe.initCause(gse);
|
||||
@ -495,6 +496,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
|
||||
}
|
||||
} else {
|
||||
_socket = new Socket(_hostname, _portNum);
|
||||
_socket.setKeepAlive(true);
|
||||
}
|
||||
// _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
|
||||
OutputStream out = _socket.getOutputStream();
|
||||
|
@ -89,6 +89,7 @@ class I2PSimpleSession extends I2PSessionImpl2 {
|
||||
} else {
|
||||
_socket = new Socket(_hostname, _portNum);
|
||||
}
|
||||
_socket.setKeepAlive(true);
|
||||
OutputStream out = _socket.getOutputStream();
|
||||
out.write(I2PClient.PROTOCOL_BYTE);
|
||||
out.flush();
|
||||
|
@ -93,6 +93,7 @@ class ClientListenerRunner implements Runnable {
|
||||
if (validate(socket)) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Connection received");
|
||||
socket.setKeepAlive(true);
|
||||
runConnection(socket);
|
||||
} else {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
|
Reference in New Issue
Block a user