- Online Community Forums » Programming Questions » AF_INET or PF_INET?

This thread is locked; no one can reply to it. rss feed Print
Member #1,772
December 2001

Which one is considered to be better style? I had a look in the man page for socket, and it showed PF_INET. However, it later refers to AF_INET further down the page. A shocking lack of consistency...

I searched the web with no good results, some people use one, some people use the other. One thing I noticed: most people who use PF_INET place it in the socket() parameter, but use AF_INET elsewhere in their program. Any reason for this, or does it even matter?


Member #2,559
July 2002

AF_INET = Address Format, Internet = IP Addresses
PF_INET = Packet Format, Internet = IP, TCP/IP or UDP/IP


According to the link, it's:

AF_INET = Address Family, Internet = IP Addresses
PF_INET = Protocol Family, Internet = IP, TCP/IP or UDP/IP

You should read the comments ::)

Tomasu: Every time you read this: hugging!

Ryan Patterson - <>

Member #1,772
December 2001

O .... K.

I think I get it now. We want to use protocol families for sockets, and address families for addresses. Makes sense. It's just a happy coincidence that they're both equal to two, and are therefore interchangeable. A coincidence that I should not rely on.

I did read the comments, but somehow their meaning escaped me...:-[


Go to: