Creates welcome socket and starts update loop to handle arbitrary sequence of clients making requests. @param port a port number @throws Exception
(int port)
| 26 | * @throws Exception |
| 27 | */ |
| 28 | @SuppressWarnings("InfiniteLoopStatement") |
| 29 | private static void start(int port) throws Exception { |
| 30 | serverSocket = new DatagramSocket(port); |
| 31 | if (System.in.available() > 0) { |
| 32 | downloadMode = true; |
| 33 | } |
| 34 | while (true) { |
| 35 | if (downloadMode) { |
| 36 | download(); |
| 37 | } else { |
| 38 | upload(); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * In download mode, server reads data from the socket and writes it to standard output. |