Class SingleThreadHttpServer

    • Field Detail

      • running

        protected boolean running
        Stores the running flag.
      • serverProcessingThread

        protected Thread serverProcessingThread
        Stores the server acceptor thread.
      • serverPort

        protected int serverPort
        Stores the port we are listening on.
      • serverSocket

        protected ServerSocket serverSocket
        Stores the server socket.
      • serverStopRequest

        protected boolean serverStopRequest
        Stores the server stop request.
      • soTimeout

        protected int soTimeout
        Stores the SO_TIMEOUT.
    • Constructor Detail

      • SingleThreadHttpServer

        public SingleThreadHttpServer()
      • SingleThreadHttpServer

        public SingleThreadHttpServer​(int serverPort)
        serverPort - the server port.
      • SingleThreadHttpServer

        public SingleThreadHttpServer​(int serverPort,
                                      HttpServerProcessor processor)
        serverPort - the server port.
        processor - the HTTP server processor.
    • Method Detail

      • isRunning

        public boolean isRunning()
        Is the server running.
        Specified by:
        isRunning in interface HttpServer
        true if it is, false otherwise.
      • run

        public void run()
        Handle the socket request.
        Specified by:
        run in interface Runnable
      • start

        public void start()
        Start the server.
        Specified by:
        start in interface HttpServer
      • stop

        public void stop()
        Stop the server.
        Specified by:
        stop in interface HttpServer