import java.io.*; import java.net.*; public class HTTPServer { public static void main(String[] args) throws Exception { final int httpd = Integer.parseInt(args[0]); // our port ServerSocket ssock = new ServerSocket(httpd); System.out.println("Have opened port " + httpd + " locally."); Socket sock = ssock.accept(); System.out.println("Client has made socket connection."); OneConnection client = new OneConnection(sock); String s = client.getRequest(); } } class OneConnection { Socket sock; BufferedReader in = null; DataOutputStream out = null; OneConnection(Socket sock) throws Exception { this.sock = sock; in = new BufferedReader (new InputStreamReader (sock.getInputStream())); out = new DataOutputStream(sock.getOutputStream()); } String getRequest() throws Exception { String s = null; while ((s = in.readLine()) != null) { System.out.println("got: " + s); } return s; } }