node-unix-dgram icon indicating copy to clipboard operation
node-unix-dgram copied to clipboard

Allow connecting to abstract namespace sockets

Open dennisjac opened this issue 8 years ago • 10 comments

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

dennisjac avatar Jun 05 '16 11:06 dennisjac

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.

dennisjac avatar Jun 08 '16 00:06 dennisjac

The test-abstract.js should be added to the scripts -> test entry in package.json. Also testing the EINVAL case would be nice.

santigimeno avatar Jun 08 '16 08:06 santigimeno

I've added the inline function and modified package.json to include the test-abstract.js file.

dennisjac avatar Jun 28 '16 00:06 dennisjac

Still, a test for the EINVAL case would be nice.

santigimeno avatar Jun 28 '16 07:06 santigimeno

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.

dennisjac avatar Jun 29 '16 20:06 dennisjac

It LGTM with the nit addressed, but I would prefer @bnoordhuis to sign off on this before merging. Thanks!!

santigimeno avatar Jun 30 '16 08:06 santigimeno

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 avatar Jul 25 '16 07:07 mvduin

@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.

santigimeno avatar Aug 18 '16 19:08 santigimeno

Any news on this one?

redneb avatar Jun 02 '19 23:06 redneb

I'm okay with this feature but the PR needs a rebase.

bnoordhuis avatar Jun 07 '19 08:06 bnoordhuis