What is the difference between AF_INET and PF_INET constants?

前端 未结 1 1951
你的背包
你的背包 2021-01-30 11:13

Looking at examples about socket programming, we can see that some people use AF_INET while others use PF_INET. In addition, sometimes both of them are

相关标签:
1条回答
  • 2021-01-30 11:24

    I think the Wikipedia notes on this sum it up pretty well:

    The original design concept of the socket interface distinguished between protocol types (families) and the specific address types that each may use. It was envisioned that a protocol family may have several address types. Address types were defined by additional symbolic constants, using the prefix AF_ instead of PF_. The AF_-identifiers are intended for all data structures that specifically deal with the address type and not the protocol family. However, this concept of separation of protocol and address type has not found implementation support and the AF_-constants were simply defined by the corresponding protocol identifier, rendering the distinction between AF_ versus PF_ constants a technical argument of no significant practical consequence. Indeed, much confusion exists in the proper usage of both forms.

    Even if someone came up with a reason to have a difference today, they'd have to come up with new identifiers or so much stuff would break...

    0 讨论(0)
提交回复
热议问题