Commit ea43d75a authored by akwizgran's avatar akwizgran

Set TCP no delay and keepalive options on socket.

parent ff7258d5
......@@ -42,9 +42,11 @@ class NetworkClient extends Thread {
while (!isInterrupted()) {
Socket s = new Socket();
try {
s.setTcpNoDelay(true);
s.setKeepAlive(true);
s.setSoTimeout(SOCKET_TIMEOUT_MS + keepaliveIntervalMs);
log.log("Connecting to " + host + ":" + port);
s.connect(new InetSocketAddress(host, port), CONNECT_TIMEOUT_MS);
s.setSoTimeout(SOCKET_TIMEOUT_MS + keepaliveIntervalMs);
log.log("Requesting keepalives every "
+ (keepaliveIntervalMs / 1000) + " seconds");
DataOutputStream out = new DataOutputStream(s.getOutputStream());
......
......@@ -55,6 +55,8 @@ public class SnoozeServer implements Runnable {
@Override
public void run() {
try {
socket.setTcpNoDelay(true);
socket.setKeepAlive(true);
socket.setSoTimeout(SOCKET_TIMEOUT_MS);
DataInputStream in = new DataInputStream(socket.getInputStream());
OutputStream out = socket.getOutputStream();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment