When writing a network program, establish a TCP socket:
Sock = socket (pf_inet, sock_stream, 0);
Then bind the address or connect to the remote address when you need to initialize the SOCKADDR_IN structure, which specifies address family when the general settings asked Af_inet, that is, the use of IP.
The associated header file definition:
AF = Address Family
PF = Protocol Family
Af_inet = Pf_inet
So in Windows, Af_inet and pf_inet are exactly the same, and in the Unix/linux system, there is a slight difference between the two in different versions. For BSD, it is AF, for POSIX is PF.
In theory, the socket is a specified protocol, should be used pf_xxxx, set the address should be used af_xxxx. Of course the values of af_inet and pf_inet are the same, and mixing is not too much of a problem.
In the function Socketpair with the socket's domain parameter, there is
Af_unix, Af_local, Af_inet, Pf_unix, pf_local, pf_inet
These parameters are Af_unix = af_local, Pf_unix = pf_local, af_local = pf_local, af_inet = pf_inet
Recommendation: The Pf_local series is used for the domain parameter of the Socketpair and socket, and af_local is used when initializing the socket interface address structure.
For example:
z = socket (pf_local, sock_stream, 0); adr_unix.sin_family = af_local;
The difference between pf_inet and af_inet