Base class for various socket-based server classes.

Defaults to synchronous IP stream (i.e., TCP).

Constructor

@:value({ bindAndActivate : true })new(serverHost:Host, serverPort:Int, requestHandlerClass:Class<BaseRequestHandler>, bindAndActivate:Bool = true)

Constructor. May be extended, do not override.

Variables

@:value(5)requestQueueSize:Int = 5

The number of pending connection until some get rejected. Passed to socket.listen().

Methods

serverActivate():Void

Called by constructor to activate the server.

May be overridden.

serverBind():Void

Called by constructor to bind the socket.

May be overridden.

Inherited Variables

Defined by BaseServer

@:value(false)threading:Bool = false

Handle each request in a new thread.

@:value(null)timeout:Null<Float> = null

A timeout to apply to the request socket, if not null.

Inherited Methods

Defined by BaseServer

handleRequest():Void

Handle one request, possibly blocking.

@:value({ pollInterval : 0.5 })serveForever(pollInterval:Float = 0.5):Void

Handle one request at a time until shutdown.

shutdown():Void

Stops the serveForever() loop.

Blocks until the loop has finished. This must be called while serveForever() is running in another thread, or it will deadlock.