run multiple connections

This commit is contained in:
jrandom
2004-11-15 14:40:08 +00:00
committed by zzz
parent 306f6b0037
commit 085da16268

View File

@ -16,7 +16,6 @@ import net.i2p.util.Log;
*/ */
public class ConnectTest { public class ConnectTest {
private Log _log; private Log _log;
private I2PSession _client;
private I2PSession _server; private I2PSession _server;
public void test() { public void test() {
try { try {
@ -26,14 +25,14 @@ public class ConnectTest {
_server = createSession(); _server = createSession();
_log.debug("running server"); _log.debug("running server");
runServer(context, _server); runServer(context, _server);
_log.debug("creating client session"); for (int i = 0; i < 5; i++) {
_client = createSession(); _log.debug("running client");
_log.debug("running client"); runClient(context, createSession());
runClient(context, _client); }
} catch (Exception e) { } catch (Exception e) {
_log.error("error running", e); _log.error("error running", e);
} }
try { Thread.sleep(30*1000); } catch (Exception e) {} try { Thread.sleep(10*60*1000); } catch (Exception e) {}
} }
private void runClient(I2PAppContext ctx, I2PSession session) { private void runClient(I2PAppContext ctx, I2PSession session) {
@ -70,7 +69,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(60*1000); } catch (InterruptedException ie) {} try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
socket.close(); socket.close();
} }
} catch (Exception e) { } catch (Exception e) {
@ -100,6 +99,9 @@ public class ConnectTest {
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {} try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
socket.close(); socket.close();
_log.debug("socket closed"); _log.debug("socket closed");
mgr.destroySocketManager();
mgr = null;
socket = null;
} catch (Exception e) { } catch (Exception e) {
_log.error("error running", e); _log.error("error running", e);
} }
@ -123,7 +125,7 @@ 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_HOST, "localhost");
System.setProperty(I2PClient.PROP_TCP_PORT, "10001"); System.setProperty(I2PClient.PROP_TCP_PORT, "11001");
ConnectTest ct = new ConnectTest(); ConnectTest ct = new ConnectTest();
ct.test(); ct.test();
} }