Reputation: 419
socketpair(int family, int type, int protocol, int* sockfd) from sys/socket.h.
unp states the family should be AF_LOCAL, the protocol should be 0, since then why should the interface require such parameters? why not simplify it as socketpair(int type, int *sockfd) ?
I believe there must be story here, but I just don't know why.
Thank you for telling me the story ;)
Upvotes: 1
Views: 786
Reputation: 3632
You should read that statement "AF_LOCAL" (or _UNIX) is currently the only protocol that implements socketpair().
The interface is generic and one could provide implementation for other types of sockets. For instance it would not be too hard to implement support for AF_INET by creating two sockets connected to each other using localhost IP. The only gotcha is that there would be little practical use for it. Unix sockets are better for local connections and changing existing socketpair API is too much trouble now.
Upvotes: 1