Package net.targetr.wtm3.net.http
Class HttpServer
java.lang.Object
net.targetr.wtm3.net.http.HttpServer
Creates a new HTTPServer that listens to a specific port.
Creates and starts new HTTPHandlers when clients connect to a port.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new web server suitable for listening to a port for connections from web clients. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the web server has entered the stopping state.voidlisten(int port, int backlog, InetAddress addr) Starts listening on a specific port for connection from web clients.voidsetResponder(ResponseGenerator responder) Sets the responder that will process requests and generate responses.voidstop()Instructs the web server to stop listening for new connections.
-
Constructor Details
-
HttpServer
public HttpServer()Creates a new web server suitable for listening to a port for connections from web clients.
-
-
Method Details
-
setResponder
Sets the responder that will process requests and generate responses.- Parameters:
responder- For responding to requests.
-
listen
public void listen(int port, int backlog, InetAddress addr) throws IOException, InterruptedException Starts listening on a specific port for connection from web clients.This method blocks until stopping.
- Parameters:
port- The port to listen for HTTP and HTTPS connections.backlog- The number of connections that can be queed before being dropped.addr- A specific network interface address to listen on or null for all.- Throws:
IOException- If there is a problem accpeting connections.InterruptedException- If there is aproblem shutting down.
-
isStopping
public boolean isStopping()Returns true if the web server has entered the stopping state.- Returns:
- true if stopping.
-
stop
public void stop()Instructs the web server to stop listening for new connections.
-