import java.io.IOException; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.SocketException; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import www.Httpd11Worker; public class Httpd11Base { public static void main(String[] argv) { ServerSocketChannel listenChannel = null; ServerSocket listenSocket = null; SocketChannel rwChan = null; Httpd11Worker worker = null; InetSocketAddress rcvAddress; int i = 1; boolean debug = false; if (argv.length < 1) { System.out.println("usage: java"+ Httpd11Base.class.getName()+" [-v] "); return; } if(argv.length == 2){ debug = true; argv[0] = argv[1]; } try { /* TODO * initialize connection channel to allow client to connect to the server * portnumber is in argv[0] */ while (i > 0) { // accept one incoming connection if(debug) System.out.println("Waiting for connection request..."); /* TODO * accept connection */ if(debug)System.out.println("Connection request accepted..."); /* TODO * create a 11Worker and treats all requests * from that connection */ } /* TODO * close the listening channel */ } catch (Exception se) { /* SocketException et IOException */ se.printStackTrace(); return; } } }