Only use a socket timeout when handshaking on the control stream.

This commit is contained in:
Cameron Gutman 2014-01-09 23:48:59 -06:00
parent ade061bf3c
commit cc30752eb7

View File

@ -64,7 +64,6 @@ public class ControlStream implements ConnectionStatusListener {
public void initialize() throws IOException public void initialize() throws IOException
{ {
s = new Socket(); s = new Socket();
s.setSoTimeout(CONTROL_TIMEOUT);
s.setTcpNoDelay(true); s.setTcpNoDelay(true);
s.connect(new InetSocketAddress(host, PORT), CONTROL_TIMEOUT); s.connect(new InetSocketAddress(host, PORT), CONTROL_TIMEOUT);
in = s.getInputStream(); in = s.getInputStream();
@ -140,10 +139,16 @@ public class ControlStream implements ConnectionStatusListener {
public void start() throws IOException public void start() throws IOException
{ {
// Use a finite timeout during the handshake process
s.setSoTimeout(CONTROL_TIMEOUT);
sendConfig(); sendConfig();
pingPong(); pingPong();
send1405AndGetResponse(); send1405AndGetResponse();
// Return to an infinte read timeout after the initial control handshake
s.setSoTimeout(0);
heartbeatThread = new Thread() { heartbeatThread = new Thread() {
@Override @Override
public void run() { public void run() {