Default Protocol for AF_UNIX Sockets

I'm curious what is the default protocol for the socket AF_UNIX SOCK_STREAM. I am trying to determine exactly what should be an overhead package, but I cannot figure out which protocol is used by default. I suspect this is not IPPROTO_TCP because it is:

socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) 

It works, and this:

 socketpair(AF_UNIX, SOCK_STREAM, IPPROTO_TCP, sfd) 

Gives a "Protocol not supported" error.

+4
source share
3 answers

Since the unix socket AF_UNIX is local, in this case there is no such thing as added protocol overhead. You can use it in SOCK_STREAM or SOCK_DGRAM mode to make it connection-oriented or connection-free, respectively, but that's it: protocol headers are not added, and it does not cross any of the networks or transport protocol implementations in the network stack.

+2
source

AF stands for A ddress F amily, while PF stands for P rotocol F amily.

The AF_UNIX family does not have the IPPROTO_TCP protocol, which is supported by this address family. AF_UNIX is designed for interprocess communication between processes on the same system in a UNIX® domain. The AF_UNIX and AF_UNIX_CCSID address families support protocol 0 for SOCK_STREAM and SOCK_DGRAM.

Read more here: Sockets

+3
source

The only valid "protocol" when using AF_UNIX is zero.

See socket (2) and unix (7)

+1
source

Source: https://habr.com/ru/post/1416193/


All Articles