public void run(){
        for(;;){
            try {
                //accept connection
                socket = serverSocket.accept();

                BufferedReader netListener = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                output = new DataOutputStream(socket.getOutputStream());

                //get string in
                String requestString = "";
                String line;
                while((line = netListener.readLine()) != null){
                    if(line.isEmpty())
                        break;
                    requestString += line + "\r\n";
                }

                //generate a request
                Request req = new Request(requestString, socket.getInetAddress().toString());

                // Grab the site to process the request with
                SiteConfiguration site;
                if(configs.get(req.getHost()) == null) {
                    // Use the * host
                    site = configs.get(SiteConfiguration.ANY_HOST);
                } else {
                    // Use the specified host
                    site = configs.get(req.getHost());
                }
                req.setSiteConfiguration(site);

                //process request
                Response res = req.process();
                if(res instanceof ErrorResponse) {
                    logError(((ErrorResponse) res).getLogMessage());
                }

                //write response to browser
                write(res.getBytes());

                //close socket
                socket.close();

            } catch (IOException e) {
                logError("IOException in PortListener: " + e.getMessage());
            } finally {
                //cleanup, if needed
                try{
                    socket.close();
                }catch (IOException e){
                    logError("IOException in PortListener: " + e.getMessage());
                }
            }
        }


    }//run