0

I've got two programs in different languages attempting to connect to a local abstract socket on a Linux system. One of the two is failing. I am having difficulty determining why. I just want to know what the one difference I can find in the strace output means, so I can fix it.

The working one has this strace output:

socket(PF_LOCAL, SOCK_SEQPACKET, 0)     = 3
connect(3, {sa_family=AF_LOCAL, sun_path=@"qwertystop.bus.8"}, 19) = 0

The nonworking has this strace output:

[pid  6307] socket(PF_LOCAL, SOCK_SEQPACKET, 0) = 13
[pid  6307] connect(13, {sa_family=AF_LOCAL, sun_path="qwertystop.bus.8"}, 19) = -1 ENOENT (No such file or directory)

There are three differences: The nonworking one is from a program with multiple pids, the return value of the connect call is different, and the working one has a @ before the sun_path string. I presume that whatever causes the @ to be missing is also what caused the failure, since it makes little sense for socket connection to not work in a process just because it was started by a different process.


(I am explicitly not requesting a general solution to "connect to an abstract socket", which is why I am not stating the languages. Mostly because this is homework and I refuse to create a situation which might tempt me to copy code directly.)

Vivian
  • 1,539
  • 14
  • 38

2 Answers2

1

Meaning determined. It means the string is preceded by a null byte. Or possibly just a non-printing character, or it's signifying that the socket is abstract.

Vivian
  • 1,539
  • 14
  • 38
0

This is a Linux thing, I think. See http://man7.org/linux/man-pages/man7/unix.7.html. It should be under "abstract socket".

Erik Bennett
  • 1,049
  • 6
  • 15
  • The `@` symbol appears nowhere in the linked document. – Vivian Apr 18 '17 at 00:26
  • Sorry. I thought you got that from the previous answer about the null-byte. The null byte at the beginning is the linux-ism. [https://superuser.com/questions/381262/linux-init-local-socket-with](https://superuser.com/questions/381262/linux-init-local-socket-with). Sorry if I was unclear. – Erik Bennett Apr 18 '17 at 14:44