nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
105.14k stars 28.49k forks source link

Sending/receiving ancillary data (FDs) over Unix domain sockets #53391

Open joepie91 opened 3 weeks ago

joepie91 commented 3 weeks ago

What is the problem this feature will solve?

Ability to send/receive ancillary data over Unix domain sockets. This is necessary for eg. implementation of the Wayland protocol (which uses this feature for high-performance sharing of memory buffers between compositors and clients), and thereby allows implementing graphical applications for Wayland systems.

What is the feature you are proposing to solve the problem?

Some kind of extension to the net core module that allows for sending file descriptors over (Unix domain) sockets, those being sent as ancillary data. Support for this seems to already exist in libuv, from what I've been able to find; it just isn't wired to the net core module in any way.

What alternatives have you considered?

I've looked through all the relevant source code in core modules (both the JS and C++ side) to figure out if there is already a way to do this, but was unable to find one; it seems that the StreamBase:Writev method hard-sets the ancillary FD to a null pointer, for instance.

Sending/receiving FDs is a hard requirement for Wayland protocol implementation, and there are no alternative mechanisms. I'm unable to write C/C++ and therefore cannot talk to libuv directly myself.

benjamingr commented 3 weeks ago

@nodejs/libuv