update connection options specification

tweak around with the connection delay and timeout activity to test delayed vs. immediate syn
This commit is contained in:
jrandom
2004-11-11 09:41:25 +00:00
committed by zzz
parent b457001b42
commit 7ec027854e
2 changed files with 9 additions and 56 deletions

View File

@ -70,7 +70,7 @@ public class ConnectTest {
while (true) {
I2PSocket socket = ssocket.accept();
_log.debug("socket accepted: " + socket);
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
try { Thread.sleep(60*1000); } catch (InterruptedException ie) {}
socket.close();
}
} catch (Exception e) {
@ -97,6 +97,7 @@ public class ConnectTest {
_log.debug("manager created");
I2PSocket socket = mgr.connect(_server.getMyDestination());
_log.debug("socket created");
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
socket.close();
_log.debug("socket closed");
} catch (Exception e) {
@ -111,7 +112,7 @@ public class ConnectTest {
I2PClient client = I2PClientFactory.createClient();
ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
Destination dest = client.createDestination(baos);
I2PSession sess = client.createSession(new ByteArrayInputStream(baos.toByteArray()), new Properties());
I2PSession sess = client.createSession(new ByteArrayInputStream(baos.toByteArray()), System.getProperties());
sess.connect();
return sess;
} catch (Exception e) {
@ -121,6 +122,8 @@ public class ConnectTest {
}
public static void main(String args[]) {
System.setProperty(I2PClient.PROP_TCP_HOST, "localhost");
System.setProperty(I2PClient.PROP_TCP_PORT, "10001");
ConnectTest ct = new ConnectTest();
ct.test();
}

View File

@ -39,24 +39,6 @@ public class ConnectTimeoutTest {
while (true) { synchronized (this) { try { wait(); } catch (Exception e) {} } }
}
public void test() {
try {
I2PAppContext context = I2PAppContext.getGlobalContext();
_log = context.logManager().getLog(ConnectTest.class);
_log.debug("creating server session");
_server = createSession();
_log.debug("running server");
runServer(context, _server);
_log.debug("creating client session");
_client = createSession();
_log.debug("running client");
runClient(context, _client);
} catch (Exception e) {
_log.error("error running", e);
}
try { Thread.sleep(30*1000); } catch (Exception e) {}
}
private void runClient(I2PAppContext ctx, I2PSession session) {
Thread t = new Thread(new ClientRunner(ctx, session));
t.setName("client");
@ -64,42 +46,6 @@ public class ConnectTimeoutTest {
t.start();
}
private void runServer(I2PAppContext ctx, I2PSession session) {
Thread t = new Thread(new ServerRunner(ctx, session));
t.setName("server");
t.setDaemon(true);
t.start();
}
private class ServerRunner implements Runnable {
private I2PAppContext _context;
private I2PSession _session;
private Log _log;
public ServerRunner(I2PAppContext ctx, I2PSession session) {
_context = ctx;
_session = session;
_log = ctx.logManager().getLog(ServerRunner.class);
}
public void run() {
try {
I2PSocketManager mgr = I2PSocketManagerFactory.createManager("localhost", 10001, getProps());
_log.debug("manager created");
I2PServerSocket ssocket = mgr.getServerSocket();
_log.debug("server socket created");
while (true) {
I2PSocket socket = ssocket.accept();
_log.debug("socket accepted: " + socket);
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
socket.close();
}
} catch (Exception e) {
_log.error("error running", e);
}
}
}
private class ClientRunner implements Runnable {
private I2PAppContext _context;
private I2PSession _session;
@ -114,6 +60,7 @@ public class ConnectTimeoutTest {
try {
I2PSocketManager mgr = I2PSocketManagerFactory.createManager("localhost", 10001, getProps());
_log.debug("manager created");
_log.debug("options: " + mgr.getDefaultOptions());
I2PSocket socket = mgr.connect(_serverDest);
_log.debug("socket created");
socket.getOutputStream().write("you smell".getBytes());
@ -155,6 +102,9 @@ public class ConnectTimeoutTest {
p.setProperty("tunnels.depthInbound", "0");
p.setProperty(I2PClient.PROP_TCP_HOST, "localhost");
p.setProperty(I2PClient.PROP_TCP_PORT, "10001");
p.setProperty(ConnectionOptions.PROP_CONNECT_TIMEOUT, "30000");
//p.setProperty(ConnectionOptions.PROP_CONNECT_DELAY, "10000");
p.setProperty(ConnectionOptions.PROP_CONNECT_DELAY, "0");
return p;
}
}