rontolisp:tcp-set-timeout
(rontolisp:tcp-set-timeout handle milliseconds)
Sets the read deadline of a connected socket handle: every subsequent blocking
read on the handle (read-line, read-char, read-byte, ...) signals an
error after milliseconds without data instead of waiting forever. On a
listener handle it is the accept deadline: a
rontolisp:tcp-accept that gets no connection within
milliseconds signals tcp-accept: Accept timed out.
milliseconds is a non-negative integer (the rontolisp:wait-for
convention), and nil clears the deadline. Returns the milliseconds
argument.
The timeout error is a plain catchable error whose message names the read
that timed out; it is not a distinct condition class. The deadline lives on
the raw socket, so it keeps governing a connection later upgraded with
rontolisp:tls-upgrade. This is the primitive
behind the usocket shim's
(setf (usocket:socket-option sock :receive-timeout) seconds) (see the
TCP Sockets guide).
Backend support
- Interpreter and JVM: real, via
Socket.setSoTimeoutandServerSocket.setSoTimeout; a count past 2147483647 waits 2147483647 milliseconds.millisecondsoutside(OR NULL (INTEGER 0))signals the operator'stype-error, and a value that is not an open socket or listener handle asimple-error. - WASM component: a real read deadline too.
wasi:sockets@0.3.0has no receive timeout of its own, so a read that has to wait for its data races a timer; a read past the deadline signalsread-line: Read timed out(the interpreter's text), and the socket can be read again afterwards, as on the interpreter and the JVM; an accept races a timer the same way.0clears the deadline likenil. A value that is not an open socket or listener answersnilthere (the component's error convention), andmillisecondsthat is notnilor a non-negative integer signals asimple-error. Call-time error in Preview 1 (core-module) mode, like every tcp built-in. - Native executable (
--native): a real read and accept deadline, as on the interpreter and the JVM; a read past it signalsread-line: Read timed out(TCP sockets in a native executable). A count past 1073741823 waits 1073741823 milliseconds, some twelve days. - Browser playground: not supported.