I’m curious what the default protocol is for an AF_UNIX SOCK_STREAM socket. I’m trying to track down exactly what the packet overhead should be, but I can’t figure out what protocol is used by default. I suspect it’s not IPPROTO_TCP because this:
socketpair(AF_UNIX, SOCK_STREAM, 0, sfd)
works while, this:
socketpair(AF_UNIX, SOCK_STREAM, IPPROTO_TCP, sfd)
Gives a “Protocol not supported error”.
Since an AF_UNIX unix socket is a local thing, there’s no such thing as added protocol overhead in this case. You can use it in SOCK_STREAM or SOCK_DGRAM mode to make it connection-oriented or connectionless, respectively, but that’s all: no protocol headers are added and it traverses none of the network or transport protocol implementations in the network stack.