// Copyright 2014, Kevin Ko <kevin@faveset.com>

package com.faveset.khttpserver;

import java.io.IOException;
import com.faveset.log.OutputStreamLog;

public class HttpServer {
    public static void main(String[] args) throws IOException {
        if (args.length < 1) {
            System.out.println("<port>");
            return;
        }

        int port = new Integer(args[0]);

        OutputStreamLog log = new OutputStreamLog(System.out);

        com.faveset.khttp.HttpServer server = new com.faveset.khttp.HttpServer();
        server.setLog(log);

        server.listenAndServe("127.0.0.1", port);

        log.close();
    }
}

@@ -104,16 +104,72 @@
 eption;%0A
+import sun.misc.Signal;%0Aimport sun.misc.SignalHandler;%0A%0A
 import c
@@ -509,16 +509,22 @@
         
+final 
 com.fave
@@ -614,24 +614,249 @@
 tLog(log);%0A%0A
+        // Set up the signal handler.%0A        Signal.handle(new Signal(%22INT%22), new SignalHandler() %7B%0A            @Override%0A            public void handle(Signal sig) %7B%0A                server.stop();%0A            %7D%0A        %7D);%0A
         serv
@@ -878,17 +878,10 @@
 ve(%22
-127.0.0.1
+::
 %22, p

Test server maps to all interfaces. Add signal handler for cleaning up on SIGINT.