start of new file
[IRC.git] / Robust / src / Interface / JhttpServer.java
1 package Interface;
2
3 //****************************************************************************
4 // Programmer: Duane M. Gran, ragnar@cs.bsu.edu
5 // Program:    JhttpServer
6 // Date:       April 24, 1998
7 //****************************************************************************
8
9 import java.net.*;
10 import java.io.*;
11
12 public class JhttpServer extends Thread{
13
14     private ServerSocket server;
15     private WebInterface webinterface;
16
17 //****************************************************************************
18 // Constructor: JhttpServer(int)
19 //****************************************************************************
20     public JhttpServer(int port, WebInterface webinterface)
21     {
22         System.out.println("starting...");
23         this.webinterface=webinterface;
24         try{
25             System.out.println("creating the port");
26             server = new ServerSocket(port);
27         }
28         catch (IOException e){
29             System.err.println(e);
30             System.exit(1);
31         }
32     }
33
34     private void startWorker(Socket client) throws Exception {
35         (new JhttpWorker(client,false,webinterface)).start();
36     }
37
38     public void run(){
39         // infinite loop 
40         while (true){
41             try{
42                 startWorker(server.accept());
43             }
44             catch (Exception e){
45                 System.err.println(e);
46             }
47         }
48     }
49 }