ServerSocket sock; Socket clientSock; try { sock = new ServerSocket(PORT); while ((clientSock = sock.accept()) != null) { // Process it. process(clientSock); } } catch (IOException e) { System.err.println(e); }
This would do something with one client. System.out.println("Accept from client " + s.getInetAddress()); // The conversation would be here. s.close();
System.out.println("Accept from client " + s.getInetAddress()); // The conversation would be here. s.close();