0

For a UDP socket, sendto() will attempt to bind an ephemeral port. For a Unix domain socket of datagram type, since there is no port concept, only a path address, does sendto() try to come up with a random path(which needs to be backed by a real file in the fs), or a random abstract path(such as '@blah'), and then binds to it?

I am asking because on my machine I see these datagram Unix socket pairs in 'ESTAB' state, and I wonder how are these endpoints identified if the address here is '*', which I guess is a NULL string?

# ss -xp | grep dev-log
u_dgr ESTAB 0      0              /run/systemd/journal/dev-log 15236             * 0      users:(("systemd-journal",pid=254,fd=3),("systemd",pid=1,fd=36))                                                                                                                                                                                                                                                                                 
# ss -xp | grep 15236
u_dgr ESTAB 0      0              /run/systemd/journal/dev-log 15236             * 0      users:(("systemd-journal",pid=254,fd=3),("systemd",pid=1,fd=36))                                                                                                                                                                                                                                                                                 
u_dgr ESTAB 0      0                                         * 19250             * 15236  users:(("dbus-daemon",pid=369,fd=14))                                                                                                                                                                                                                                                                                                            
u_dgr ESTAB 0      0                                         * 21686             * 15236  users:(("dbus-daemon",pid=701,fd=10)) 

                                                                                                                                                                                                                                                                                                       

A related question is, what are those numbers in place of port numbers mean, in unix domain socket world?

QnA
  • 1,035
  • 10
  • 25
  • https://man7.org/linux/man-pages/man7/unix.7.html this says there are unnamed sockets. – user253751 Jul 06 '22 at 15:43
  • Thanks. So my understanding is, for a connectionless socket to be in ESTAB state, it is blocked in `recvfrom()` function, with destination address specified already. If that is correct, then it has to identify itself to the destination address (and unnamed sockets can not do that, I suppose), otherwise how can the destination party know where to send back? – QnA Jul 06 '22 at 15:55

0 Answers0