uSockets icon indicating copy to clipboard operation
uSockets copied to clipboard

Add support for already-listening sockets

Open shivak opened this issue 2 years ago • 6 comments

Background. It's often desirable to work off a given listening fd, rather than opening a port or UNIX domain socket. For example, a listening FD can be passed from a process in a global network namespace to a server in a restricted namespace, for security/isolation. In systemd socket activation, the externally-facing network or domain socket is bound and listened by systemd. When a new connection arrives, the service is started with the socket descriptor passed as an int in the LISTEN_FDS environment variable.

Implementation. us_socket_context_listen_direct hastily added without tests or examples. Should probably be renamed, since it takes a listening socket, but doesn't call listen() itself. Just want to get this ball rolling, in the hopes that this mode is eventually supported by Bun. With node, it's possible to run servers directly in this manner. cc @Jarred-Sumner

shivak avatar Jan 05 '23 23:01 shivak