Package kilim.http
Class HttpServer
java.lang.Object
kilim.http.HttpServer
A very rudimentary HTTP server bound to a specific given port.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpServer(int port, Class<? extends HttpSession> httpSessionClass) Creates a separate thread and a selector for the select loop and callslisteninvalid reference
#listen(int, Class)HttpServer(int port, HttpSession.StringRouter handler) HttpServer(int port, NioSelectorScheduler.SessionFactory factory) -
Method Summary
Modifier and TypeMethodDescriptionvoidlisten(int port, Class<? extends HttpSession> httpSessionClass, Scheduler httpSessionScheduler) 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.voidlisten(int port, NioSelectorScheduler.SessionFactory factory, Scheduler httpSessionScheduler)
-
Field Details
-
nio
-
-
Constructor Details
-
HttpServer
public HttpServer() -
HttpServer
Creates a separate thread and a selector for the select loop and callslisteninvalid reference
#listen(int, Class)- 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
- Throws:
IOException
-
HttpServer
- 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 connectionhttpSessionScheduler- 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
-