2023-04-05

(sph server)

a generic socket data processing server that uses a thread-pool for parallel request processing.

part of sph-lib

library description

starting the server with server-listen makes it listen on an existing or newly created socket.

if there is a new connection on the socket, a user supplied procedure is called with a client port to receive and send data

module name

(sph server)

exported bindings

variable: server-default-port
procedure: server-listen handle-request socket #:parallelism #:exception-key ->
procedure:{port:client -> unspecified} port:socket [#:key parallelism integer/false] -> unspecified
listen for new connections on socket and call handle-request with a input/output port for the client.
handle-request is called in the next free thread in a thread-pool.
the server is stopped when it receives the signal SIGINT or SIGTERM.
by default all exceptions are catched, printed and the server continues listening.
this can be changed with giving a different exception-key, which is passed to catch,
for example one that will never be matched
procedure: server-socket address #:port #:type #:protocol #:set-options #:non-blocking ->
create a socket with default options. the socket type is inferred
from the address, which can be an ip4 or ip6 address (tcp) or a filesystem path (unix socket)
variable: sph-server-description