Skip to content
Snippets Groups Projects
Commit 3e8c6081 authored by akwizgran's avatar akwizgran
Browse files

Use an unlimited read timeout for TCP sockets.

parent e8a4d778
No related branches found
No related tags found
No related merge requests found
......@@ -146,6 +146,7 @@ class LanTcpPlugin extends TcpPlugin {
try {
// Connect back on the advertised TCP port
Socket s = new Socket(packet.getAddress(), port);
s.setSoTimeout(0);
return new TcpTransportConnection(s);
} catch(IOException e) {
if(LOG.isLoggable(WARNING))
......@@ -286,7 +287,9 @@ class LanTcpPlugin extends TcpPlugin {
try {
int wait = (int) (Math.min(end, nextPacket) - now);
ss.setSoTimeout(wait < 1 ? 1 : wait);
return new TcpTransportConnection(ss.accept());
Socket s = ss.accept();
s.setSoTimeout(0);
return new TcpTransportConnection(s);
} catch(SocketTimeoutException e) {
now = System.currentTimeMillis();
if(now < end) {
......@@ -310,12 +313,4 @@ class LanTcpPlugin extends TcpPlugin {
}
return null;
}
private void tryToClose(ServerSocket ss) {
try {
ss.close();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
}
}
}
......@@ -99,7 +99,7 @@ abstract class TcpPlugin implements DuplexPlugin {
acceptContactConnections(ss);
}
private void tryToClose(ServerSocket ss) {
protected void tryToClose(ServerSocket ss) {
try {
ss.close();
} catch(IOException e) {
......@@ -120,6 +120,7 @@ abstract class TcpPlugin implements DuplexPlugin {
Socket s;
try {
s = ss.accept();
s.setSoTimeout(0);
} catch(IOException e) {
// This is expected when the socket is closed
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
......@@ -179,6 +180,7 @@ abstract class TcpPlugin implements DuplexPlugin {
Socket s = new Socket();
if(addr == null || s == null) return null;
try {
s.setSoTimeout(0);
s.connect(addr);
return new TcpTransportConnection(s);
} catch(IOException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment