Made a simple client server. Did a cycle
while (connected) { try { in = new BufferedReader(new InputStreamReader(fromClient.getInputStream())); System.out.print("Message got: " + in.toString() + "\n"); out = new PrintWriter(fromClient.getOutputStream(), true); System.out.print("Message sent: " + out.toString() + "\n"); } catch (IOException e) { System.out.print("Cannot get input stream from client\n"); } } Is this technically correct? Is it possible to make the server execute only if the client sends a message? Or just put Thread.sleep(1000);
And another such question. Do I need to recreate the socket. Or make it a global static variable?
InputStream.readblocks, so the server only performs if the client turns out by itself), which socket you are going to re-create is also unclear. - zRrr