Package kilim.http

Class HttpServer

java.lang.Object
kilim.http.HttpServer

public class HttpServer extends Object
A very rudimentary HTTP server bound to a specific given port.
  • Field Details

  • Constructor Details

    • HttpServer

      public HttpServer()
    • HttpServer

      public HttpServer(int port, Class<? extends HttpSession> httpSessionClass) throws IOException
      Creates a separate thread and a selector for the select loop and calls
      invalid reference
      #listen(int, Class)
      listen
      Parameters:
      port - . Port to listen for http connections.
      httpSessionClass - An instance of the supplied class is created and bound to the incoming socket connection, and the task is scheduled for execution on the default scheduler.
      Throws:
      IOException
    • HttpServer

      public HttpServer(int port, NioSelectorScheduler.SessionFactory factory) throws IOException
      Throws:
      IOException
    • HttpServer

      public HttpServer(int port, HttpSession.StringRouter handler) throws IOException
      Throws:
      IOException
  • Method Details

    • listen

      public void listen(int port, Class<? extends HttpSession> httpSessionClass, Scheduler httpSessionScheduler) throws IOException
      Sets up a listener on the supplied port, and when a fresh connection comes in, it creates a new instance of the httpSessionClass task and exceutes it on the supplied scheduler. It is the httpSession task's responsbility to close the socket.
      Parameters:
      port - . Port to listen for http connections.
      httpSessionClass - class of task to instantiation on incoming connection
      httpSessionScheduler - the scheduler on which to schedule the http session task.
      Throws:
      IOException
    • listen

      public void listen(int port, NioSelectorScheduler.SessionFactory factory, Scheduler httpSessionScheduler) throws IOException
      Throws:
      IOException