import java.io.*; import java.net.*; class OneConnection_C extends OneConnection_B implements Runnable { OneConnection_C(Socket sock) throws Exception { super(sock); } public void run() { try { String filename = getRequest(); sendFile(filename); } catch (Exception e) { System.out.println("Excpn: " + e);} } } // The main program will have the server socket and it will put the accept in a loop, // so that we can handle many requests, not just the first one. // It will instantiate our connection class as before, turn it into a thread, // and invoke its start method. public class HTTPServer4 { public static void main(String a[]) throws Exception { final int httpd = 80; ServerSocket ssock = new ServerSocket(httpd); while (true) { Socket sock = ssock.accept(); System.out.println("client has made socket connection"); OneConnection_C client = new OneConnection_C(sock); new Thread(client).start(); } } }