Commit890184e5Recorded29 Mar 2026Repositorysigil-socket

Add host binding support to tcp-listen

Message

tcp-listen now accepts an optional third parameter (host string) to bind to a specific network address instead of all interfaces. When a host is provided, getaddrinfo resolves it to the correct address family (IPv4 or IPv6) and binds accordingly. When omitted, the existing IPv6 dual-stack behavior is preserved.

http-server-start now passes the configured host through to tcp-listen, making the host: parameter on make-http-server functional.

Needed for Vigil deployment on OpenBSD where the server must bind to the WireGuard VPN address (10.0.0.1) only. OpenBSD's IPv6 dual-stack does not forward IPv4 connections, so wildcard binding was insufficient.

Changed
 src/sigil/socket.sgl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Diff
src/sigil/socket.sglmodified
@@ -120,7 +120,7 @@
120
;;; (tcp-listen 8080) ; => #<socket>
121
;;; ```
122
(%set-docstring! tcp-listen)
123
(%set-spec! tcp-listen '(integer? -> (maybe socket?)))
+123
(%set-spec! tcp-listen '(integer? (backlog: integer?) (host: string?) -> (maybe socket?)))
124
125
;;; Accept an incoming connection on a listening socket.
126
;;;