| 23 | public static final int PORT = 1234; |
| 24 | |
| 25 | public static void main(String[] args) throws Exception { |
| 26 | ServerSocket s = new ServerSocket(PORT); |
| 27 | |
| 28 | new IdleClient().start(); |
| 29 | OutputStream idleClient = s.accept().getOutputStream(); |
| 30 | |
| 31 | new BusyClient().start(); |
| 32 | OutputStream busyClient = s.accept().getOutputStream(); |
| 33 | |
| 34 | byte[] buf = new byte[4096]; |
| 35 | ThreadLocalRandom.current().nextBytes(buf); |
| 36 | |
| 37 | for (int i = 0; ; i++) { |
| 38 | if ((i % 10_000_000) == 0) { |
| 39 | idleClient.write(buf, 0, 1); |
| 40 | } else { |
| 41 | busyClient.write(buf); |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | } |