Can not connect to an abstract unix socket in python Can not connect to an abstract unix socket in python unix unix

Can not connect to an abstract unix socket in python


Your C++ doesn't do quite what you think it does. This line:

strncpy(addr.sun_path, UD_SOCKET_PATH, sizeof(addr.sun_path)-1);

Copies a single null character '\0' into addr.sun_path. Note this line in the manpage for strncpy():

If the length of src is less than n, strncpy() writes additional null bytes to dest to ensure that a total of n bytes are written.

As a result your C++ actually connects to an abstract domain socket at "\0". Python does the right thing here and connects to an abstract domain socket at "\0hidden".