Skip to content

Commit f2643b3

Browse files
committed
Fix seperate client/server behaviour
1 parent 1ab0c64 commit f2643b3

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Diff for: hiccup/src/main/java/com/higherfrequencytrading/hiccup/TcpHiccupMain.java

+17-14
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,35 @@ public static void main(String... args) throws IOException {
4747
String hostname = "localhost";
4848
int port = 65432;
4949

50-
for (int i = 0; i < TESTS; i++) {
51-
for (int busy = 0; busy <= 1; busy++) {
52-
BUSY = busy != 0;
50+
switch (args.length) {
51+
case 0:
52+
for (int i = 0; i < TESTS; i++) {
53+
for (int busy = 0; busy <= 1; busy++) {
54+
BUSY = busy != 0;
5355

54-
switch (args.length) {
55-
case 0:
5656
Thread thread = new Thread(new Acceptor(port + i));
5757
thread.setDaemon(true);
5858
thread.start();
5959
new Sender(hostname, port + i).run();
6060
thread.interrupt();
61-
break;
61+
}
62+
}
63+
break;
6264

63-
case 1:
64-
new Acceptor(port).run();
65-
// only run one.
66-
return;
65+
case 1:
66+
new Acceptor(port).run();
67+
// only run one.
68+
return;
6769

68-
case 2:
69-
new Sender(hostname, port).run();
70-
break;
70+
case 2:
71+
for (int i = 0; i < TESTS; i++) {
72+
new Sender(hostname, port).run();
7173
}
72-
}
74+
break;
7375
}
7476
}
7577

78+
7679
static class Acceptor implements Runnable {
7780
private final ServerSocketChannel ssc;
7881

0 commit comments

Comments
 (0)