node-unix-dgram
node-unix-dgram copied to clipboard
Allow connecting to abstract namespace sockets
Hi, I'm currently using node-unix-dgram to implement systemd service notification support for javascript and ran into the problem that systemd can use abstract namespace sockets instead of filesystem based ones. The difference is that for abstract namespace sockets the path begins with a 0-byte but other than that they behave like regular filesystem based sockets. I made some minor changes to the Connect function so that it works correctly in this case. These changes are transparent and shouldn't affect the use of filesystem based sockets in any way (I tested both cases).
Regards, Dennis
I updated the PR so that abstract namespace sockets are now fully supported for sendTo
and bind
as well.
I also had to modify onRecv() so that the source address is correctly returned for the abstract namespace socket case as well and I added a test.
The test-abstract.js
should be added to the scripts -> test entry in package.json
.
Also testing the EINVAL
case would be nice.
I've added the inline function and modified package.json to include the test-abstract.js file.
Still, a test for the EINVAL
case would be nice.
Removed the res
variable (not sure why I didn't see that I could use err
the first time) and added a test for the EINVAL case.
It LGTM with the nit addressed, but I would prefer @bnoordhuis to sign off on this before merging. Thanks!!
Since "paths" in the abstract namespace are basically just opaque binary data, wouldn't it be more appropriate to use a buffer rather than a string for them (in recv) ?
@mvduin It makes sense. The problem I see is that the API would be different for UNIX and abstract sockets and that could be confusing.
Any news on this one?
I'm okay with this feature but the PR needs a rebase.