import java.net.*; import java.io.*; public class Server { public static void main(String[] args) throws IOException { ServerSocket serverSocket = null; Socket clientSocket = null; BufferedReader in = null; String inputLine; try { serverSocket = new ServerSocket(5432); } catch (IOException e) { System.err.println("Could not listen on port: 5432."); System.exit(1); } while (true) { try { clientSocket = serverSocket.accept(); } catch (IOException e) { System.err.println("Accept failed."); System.exit(1); } in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); } clientSocket.close(); } } }