         }
     }
 
+    // Nest handler
     public func serve(handler: Application) {
         while (true) {
             if (listen(socket.raw, 100) != 0) {


import Nest

public typealias HTTPHandler = (RequestType, HTTPResponseWriter) throws -> ()

public struct HTTPServer {


            }
        }
    }

    // native handler - deprecated
    @available(*, deprecated)
    public func serve(handler: HTTPHandler) {
        while (true) {
            if (listen(socket.raw, 100) != 0) {
                return
            }
            let client = accept(socket.raw, nil, nil)
            defer {
                shutdown(client, Int32(SHUT_RDWR))
                close(client)
            }
            let reader = SocketReader(socket: Socket(raw: client))
            let writer = HTTPResponseWriter(socket: client)
            do {
                try handler(HTTPRequest.Parser.parse(reader), writer)
            }
            catch let e {
                fputs("error: \(e)\n", stderr)
            }
        }
    }
}
