You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add AF_UNIX named (pathname) stream socket support under NODERAWSOCKETS (emscripten-core#27424)
Named unix-domain sockets let POSIX code compiled to wasm participate in
the host's unix-socket IPC as a first-class client or server: connect()
to a daemon path (docker.sock, postgres/redis) or
bind()+listen()+accept() a path that native tools connect into. This is
a straight remap of the existing node:net TCP flow from (host, port) to
(path), reusing the same readiness/poll seam so mio/tokio IPC types work
unmodified.
The socket path lives in the host filesystem (node owns it), so it only
stays coherent with the program's own file syscalls - bind's parent
directory, getsockname, unlink - when the program's FS is the host FS.
The family is therefore gated behind NODERAWFS; requesting AF_UNIX
otherwise returns EAFNOSUPPORT rather than half-working against a
disjoint MEMFS namespace.
- Address plumbing: add AF_UNIX and sockaddr_un to struct info;
readSockaddr/ writeSockaddr encode/decode sun_path (pathname, unnamed,
and Linux abstract '\0' names), and the socket syscalls pass unix paths
verbatim rather than through the IP DNS layer.
- createSocket accepts AF_UNIX only under NODERAWFS (datagram ->
EPROTONOSUPPORT; the IPPROTO_TCP guard is INET-only, unix uses protocol
0).
- Backend: synchronous bind reserving the filesystem entry (bind-time
EADDRINUSE), server.listen on the bound handle, onconnection accept
queue, connect-by-path through the shared wireConnection, and
getsockname/getpeername reporting the tracked path. Bind prefers
net.BoundSocket({ path }) when the node build exposes it (detected via
'isPipe' in BoundSocket.prototype), else falls back to the private
pipe_wrap binding - mirroring the existing useBoundSocket() -> tcp_wrap
seam.
- Tests (NODERAWSOCKETS + NODERAWFS): self-contained named accept+echo
(bind/ listen/getsockname/accept/getpeername/connect),
connect-to-missing-path -> ENOENT, and rebind -> EADDRINUSE. All also
build and run natively.
socketpair()/UnixStream::pair() remains unimplemented (ENOSYS) for now.
0 commit comments