import java.io.*; import java.net.*; class ServerExample extends Thread { Socket socket; public static final int PORT = 1234; public ServerExample(Socket socket) { this.socket = socket; } public void run() { try { BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); PrintWriter pr = new PrintWriter(new OutputStreamWriter(socket.getOutputStream())); String s = br.readLine(); System.out.println("Received " + s); pr.println("Thank you for your input"); pr.flush(); } catch (IOException ioe) { System.out.println("Got IO Exception: " + ioe.getMessage()); } } public static void main(String argv[]) { try { ServerSocket ss = new ServerSocket(PORT); while (true) { Socket s = ss.accept(); new ServerExample(s).start(); } } catch (IOException ioe) { System.out.println("Got IO Exception: " + ioe.getMessage()); } } }