lajdlksadlmla
[rmh3093.git] / lab10 / MyWebServer.java
blob1ba69312c75f3b424fab7a5205cd36de22fb9d36
1 /*
2 * MyWebServer.java
4 * Version:
5 * $Id: MyWebServer.java,v 1.1 2008/05/15 22:21:43 rmh3093 Exp rmh3093 $
7 * Revisions:
8 * $Log: MyWebServer.java,v $
9 * Revision 1.1 2008/05/15 22:21:43 rmh3093
10 * Initial revision
14 import java.io.IOException;
15 import java.net.ServerSocket;
16 import java.util.LinkedList;
18 /**
19 * @author rmh3093
22 public class MyWebServer {
24 LinkedList<Servant> activeServants = new LinkedList<Servant>();
26 /**
27 * Create a new web server
29 public MyWebServer() {
30 while (true) {
31 try {
32 ServerSocket socket = new ServerSocket(0);
33 int port = socket.getLocalPort();
34 System.out.println("Listening for connection on port: " + port);
35 activeServants.add(new Servant(socket.accept()));
36 System.out.println("Serving connection on port: " + port);
37 new Thread(activeServants.getLast()).start();
38 } catch (IOException e) {
43 /**
44 * @param args [ignored]
46 public static void main(String[] args) {
47 new MyWebServer();