Commit 653ca7e6 authored by akwizgran's avatar akwizgran

Set socket timeout for server.

parent 673f31e8
......@@ -7,25 +7,12 @@ android {
applicationId "org.briarproject.snooze"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
versionCode 10000
versionName "1.0.0"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'org.jetbrains:annotations-java5:15.0'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
......
......@@ -7,6 +7,8 @@ import java.net.Socket;
public class SnoozeServer implements Runnable {
private static final int SOCKET_TIMEOUT_MS = 5 * 60 * 1000;
private final int port, writeIntervalMs;
public SnoozeServer(int port, int writeIntervalMs) {
......@@ -57,6 +59,7 @@ public class SnoozeServer implements Runnable {
@Override
public void run() {
try {
socket.setSoTimeout(SOCKET_TIMEOUT_MS);
OutputStream out = socket.getOutputStream();
while (!socket.isClosed()) {
System.out.println("Writing: " + socket.getRemoteSocketAddress());
......@@ -65,7 +68,7 @@ public class SnoozeServer implements Runnable {
}
System.out.println("Socket closed: " + socket.getRemoteSocketAddress());
} catch (IOException | InterruptedException e) {
System.err.println(e.toString());
System.err.println(e.toString() + " for " + socket.getRemoteSocketAddress());
}
}
}
......
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