update connection options specification
tweak around with the connection delay and timeout activity to test delayed vs. immediate syn
This commit is contained in:
@ -70,7 +70,7 @@ public class ConnectTest {
|
|||||||
while (true) {
|
while (true) {
|
||||||
I2PSocket socket = ssocket.accept();
|
I2PSocket socket = ssocket.accept();
|
||||||
_log.debug("socket accepted: " + socket);
|
_log.debug("socket accepted: " + socket);
|
||||||
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
|
try { Thread.sleep(60*1000); } catch (InterruptedException ie) {}
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -97,6 +97,7 @@ public class ConnectTest {
|
|||||||
_log.debug("manager created");
|
_log.debug("manager created");
|
||||||
I2PSocket socket = mgr.connect(_server.getMyDestination());
|
I2PSocket socket = mgr.connect(_server.getMyDestination());
|
||||||
_log.debug("socket created");
|
_log.debug("socket created");
|
||||||
|
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
||||||
socket.close();
|
socket.close();
|
||||||
_log.debug("socket closed");
|
_log.debug("socket closed");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -111,7 +112,7 @@ public class ConnectTest {
|
|||||||
I2PClient client = I2PClientFactory.createClient();
|
I2PClient client = I2PClientFactory.createClient();
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
|
||||||
Destination dest = client.createDestination(baos);
|
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();
|
sess.connect();
|
||||||
return sess;
|
return sess;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -121,6 +122,8 @@ public class ConnectTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
|
System.setProperty(I2PClient.PROP_TCP_HOST, "localhost");
|
||||||
|
System.setProperty(I2PClient.PROP_TCP_PORT, "10001");
|
||||||
ConnectTest ct = new ConnectTest();
|
ConnectTest ct = new ConnectTest();
|
||||||
ct.test();
|
ct.test();
|
||||||
}
|
}
|
||||||
|
@ -39,24 +39,6 @@ public class ConnectTimeoutTest {
|
|||||||
while (true) { synchronized (this) { try { wait(); } catch (Exception e) {} } }
|
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) {
|
private void runClient(I2PAppContext ctx, I2PSession session) {
|
||||||
Thread t = new Thread(new ClientRunner(ctx, session));
|
Thread t = new Thread(new ClientRunner(ctx, session));
|
||||||
t.setName("client");
|
t.setName("client");
|
||||||
@ -64,42 +46,6 @@ public class ConnectTimeoutTest {
|
|||||||
t.start();
|
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 class ClientRunner implements Runnable {
|
||||||
private I2PAppContext _context;
|
private I2PAppContext _context;
|
||||||
private I2PSession _session;
|
private I2PSession _session;
|
||||||
@ -114,6 +60,7 @@ public class ConnectTimeoutTest {
|
|||||||
try {
|
try {
|
||||||
I2PSocketManager mgr = I2PSocketManagerFactory.createManager("localhost", 10001, getProps());
|
I2PSocketManager mgr = I2PSocketManagerFactory.createManager("localhost", 10001, getProps());
|
||||||
_log.debug("manager created");
|
_log.debug("manager created");
|
||||||
|
_log.debug("options: " + mgr.getDefaultOptions());
|
||||||
I2PSocket socket = mgr.connect(_serverDest);
|
I2PSocket socket = mgr.connect(_serverDest);
|
||||||
_log.debug("socket created");
|
_log.debug("socket created");
|
||||||
socket.getOutputStream().write("you smell".getBytes());
|
socket.getOutputStream().write("you smell".getBytes());
|
||||||
@ -155,6 +102,9 @@ public class ConnectTimeoutTest {
|
|||||||
p.setProperty("tunnels.depthInbound", "0");
|
p.setProperty("tunnels.depthInbound", "0");
|
||||||
p.setProperty(I2PClient.PROP_TCP_HOST, "localhost");
|
p.setProperty(I2PClient.PROP_TCP_HOST, "localhost");
|
||||||
p.setProperty(I2PClient.PROP_TCP_PORT, "10001");
|
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;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user