Creates client socket makes request to the server. @throws Exception
(String host, int port)
| 25 | * @throws Exception |
| 26 | */ |
| 27 | @SuppressWarnings("InfiniteLoopStatement") |
| 28 | private static void start(String host, int port) throws Exception { |
| 29 | clientSocket = new DatagramSocket(); |
| 30 | ipAddress = InetAddress.getByName(host); |
| 31 | if (System.in.available() > 0) { |
| 32 | uploadMode = true; |
| 33 | } |
| 34 | while (true) { |
| 35 | if (uploadMode) { |
| 36 | upload(port); |
| 37 | } else { |
| 38 | download(port); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * In download mode, client reads data from the socket and writes it to standard output. |