I just started with network programming. When looking at the socket function some use PF_INET and others use AF_INET. Looked in wikipedia, it says such design was used to enable the usage of different address families by different protocol families. Are there any such protocol families today which support multiple address types?
Also I came across this error when I was searching for Address family Vs Protocol family:
Address family not supported by protocol family
Does this mean there are protocols supporting multiple address families?
I came across this statement
you shouldn't necessarily expect to be able to use NS addresses with ARPA Internet protocols
What are NS addresses?
Thanks.
The address family parameter (address_family) on a socket() API determines the format of the address structure to be used on socket APIs. Address family protocols provide the network transportation of application data from one application to another (or from one process to another within the same system).
A family protocol is a document or contract where a set of agreements between family members are set out. Families that own a family business often need to establish the rules that regulate: their relations with the Company, the way to solve conflicts, hiring, how to achieve the continuity of the company over time…
Sockets have two primary properties controlling the way they send data: the address family controls the OSI network layer protocol used and the socket type controls the transport layer protocol. Python supports three address families. The most common, AF_INET, is used for IPv4 Internet addressing.
A protocol is a standard set of rules for transferring data, such as UDP/IP and TCP/IP. An application program can specify a protocol only if more than one protocol is supported for this particular socket type in this domain. Each socket can have a specific protocol associated with it.
The Windows documentation for socket
says that the address family is the first argument; the man page on my Linux box says that that should be the protocol family. The Linux version seems slightly more correct from a platform-agnostic perspective -- in theory, the socket has a protocol family and the addresses have address families, and the two should be compatible.
In practice, though, the PF_
and AF_
macros for the built-in protocols have the same values (in both Linux and Windows). I imagine it's a similar story for most OSes, since all the common protocol families have one address family. (You'd think IP would have two, but nope. There are separate protocol families for IPv4 and IPv6.) This (along with C's relatively weak typing) allows them to be used pretty much interchangeably.
Note that there's no guarantee about this being the case for all OSes, or for protocols supported by some third-party driver, etc. In those cases, you should consult the documentation for your particular platform.
As for what "NS addresses" are, far as i can tell, they're part of Xerox's prehistoric Network Systems protocol (a protocol family sorta like TCP/IP, but distinct and incompatible and unused by modern PCs). You won't see them in use unless you're working with archaic systems; why that was kept as an example is beyond me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With