Threaded servers


The io.servers vocabulary implements a generic server abstraction for Connection-oriented networking. A set of threads listen for connections, and additional threads are spawned for each client connection. In addition to this basic functionality, it provides some advanced features such as logging, connection limits and secure socket support.
Threaded server examples

Creating threaded servers with client handler quotations:
<threaded-server> ( encoding -- threaded-server )


Client handlers can also be implemented by subclassing a threaded server; see Client handler quotation for details:
threaded-server

new-threaded-server ( encoding class -- threaded-server )

handle-client* ( threaded-server -- )


The server must be configured before it can be started.
Threaded server configuration

Starting the server:
start-server ( threaded-server -- threaded-server )


Stopping the server:
stop-server ( threaded-server -- )


Waiting for the server to stop:
wait-for-server ( threaded-server -- )


Combinator for running a server:
with-threaded-server ( threaded-server quot -- )


From within the dynamic scope of a client handler, several words can be used to interact with the threaded server:
stop-this-server ( -- )

secure-addr ( -- addrspec )

insecure-addr ( -- addrspec )


Additionally, the local-address and
remote-address


variables are set, as in with-client.