rontolisp:tcp-accept
(rontolisp:tcp-accept listener)
Blocks until a client connects to the given listener handle (from
rontolisp:tcp-listen) and returns a
bidirectional stream handle for the accepted connection — the same kind of
handle rontolisp:tcp-connect returns, usable
with read-line, write-line, read-byte, write-byte and close.
The example is self-contained: because the client connects before the accept, the connection waits in the listen backlog and the single-threaded program never blocks for long:
Backend support
- Interpreter and JVM:
java.net.ServerSocket.accept(); accepting on a closed listener signals an error. - WASM: component-only. The accept is a cooperatively blocking read of one
tcp-sockethandle from thewasi:sockets@0.3.0accept stream. Returnsnilif accepting fails. Compile error in Preview 1 (core-module) mode. - Browser playground: not supported.
Limitations
- Blocks indefinitely until a client connects; there is no timeout parameter.
- One connection is served per call — accept again for the next client (see
the server loop under
rontolisp:tcp-listen).