In upload mode, server reads data from its standard input device and writes it to the socket. @throws Exception
()
| 97 | * @throws Exception |
| 98 | */ |
| 99 | private static boolean upload() throws Exception { |
| 100 | boolean complete = false; |
| 101 | if (inFromClient == null) { |
| 102 | inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); |
| 103 | } |
| 104 | |
| 105 | long startTime = System.currentTimeMillis(); |
| 106 | Runnable runnable = new Runnable() { |
| 107 | @Override |
| 108 | public void run() { |
| 109 | String line = null; |
| 110 | while (true) { |
| 111 | try { |
| 112 | if (!((line = inFromClient.readLine()) != null)) break; |
| 113 | } catch (IOException e) { |
| 114 | e.printStackTrace(); |
| 115 | } |
| 116 | System.out.println(line); |
| 117 | // complete = true; |
| 118 | long endTime = System.currentTimeMillis(); |
| 119 | if(endTime-startTime > 3000){ |
| 120 | break; |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | }; |
| 125 | Thread thread = new Thread(runnable); |
| 126 | thread.start(); |
| 127 | System.out.print("aaaaaaaaaaaaaaaaaaaaa"); |
| 128 | return complete; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Starts execution of the program, requiring a port number as an argument. |