mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
DuplexOutgoingSession flushes its output stream if it's idle for a transport-defined interval, causing an empty frame to be sent. The TCP and Tor plugins use a socket timeout equal to twice the idle interval to detect dead connections. See bugs #27, #46 and #60.
38 lines
1.2 KiB
Java
38 lines
1.2 KiB
Java
package org.briarproject.plugins.tcp;
|
|
|
|
import java.util.Collections;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
|
|
import org.briarproject.api.TransportConfig;
|
|
import org.briarproject.api.TransportProperties;
|
|
import org.briarproject.plugins.DuplexServerTest;
|
|
|
|
// This is not a JUnit test - it has to be run manually while the client test
|
|
// is running on another machine
|
|
public class LanTcpServerTest extends DuplexServerTest {
|
|
|
|
private static final int MAX_FRAME_LENGTH = 1024;
|
|
private static final int MAX_LATENCY = 60 * 1000;
|
|
private static final int MAX_IDLE_TIME = 30 * 1000;
|
|
private static final int POLLING_INTERVAL = 60 * 1000;
|
|
|
|
private LanTcpServerTest(Executor executor) {
|
|
callback = new ServerCallback(new TransportConfig(),
|
|
new TransportProperties(),
|
|
Collections.singletonMap(contactId, new TransportProperties()));
|
|
plugin = new LanTcpPlugin(executor, callback, MAX_FRAME_LENGTH,
|
|
MAX_LATENCY, MAX_IDLE_TIME, POLLING_INTERVAL);
|
|
}
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
ExecutorService executor = Executors.newCachedThreadPool();
|
|
try {
|
|
new LanTcpServerTest(executor).run();
|
|
} finally {
|
|
executor.shutdown();
|
|
}
|
|
}
|
|
}
|