Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Python or Java support UNIX domain socket in abstract namespace?

Like this

abstract: an abstract socket address is distinguished by the fact that sun_path[0] is a null byte ('\0'). The socket's address in this namespace is given by the additional bytes in sun_path that are covered by the specified length of the address structure. (Null bytes in the name have no special significance.) The name has no connection with filesystem pathnames. When the address of an abstract socket is returned by getsockname(2), getpeername(2), and accept(2), the returned addrlen is greater than sizeof(sa_family_t) (i.e., greater than 2), and the name of the socket is contained in the first (addrlen - sizeof(sa_family_t)) bytes of sun_path. The abstract socket namespace is a nonportable Linux extension.

I want to connect the socket which has been create in abstract namespace(@xxx or \0xxx).

like image 760
Robert Avatar asked Jul 13 '26 04:07

Robert


1 Answers

Support for "Linux abstract socket namespace" has been in Python since version 2.5 2006.

That's according to the source and changelog. Misc/HISTORY (note: big file)

Patch #1062014: AF_UNIX sockets under Linux have a special abstract namespace that is now fully supported.

It's not mentioned in the Python2 docs but is explicitly mentioned in the latest Python 3 socket docs

Have you tried it under Python2?

As for Java, it doesn't even support AF_UNIX sockets directly; it requires JNI. There are many implementations (search around) but you will almost certainly need to do some C development to get Linux abstract namespace support.

You might try Jtux It's a complete UNIX api library for Java and of course includes AF_UNIX sockets.

like image 99
Matthew Hannigan Avatar answered Jul 14 '26 18:07

Matthew Hannigan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!