By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

AF_INET PF_INET difference - socket programming

P: 1
In socket programming in C++ WIN32 / UNIX / LINUX , we use AF_INET for Address family and PF_NET for protocol family.

socket( AF_INET, SOCK_STREAM, IPPROTO_IP )
serv_addr.sin_family = AF_INET;

socket( PF_INET, SOCK_STREAM, IPPROTO_IP )
serv_addr.sin_family = PF_INET;

I would like to know where we need to use AF_NET & PF_NET respectively?
Oct 21 '07 #1
Share this Question
Share on Google+
1 Reply


ashitpro
Expert 100+
P: 542
AF_* stands for Address Family
PF_* stands for Protocol Family

BSD man page promises:
"The protocol family generally is the same as the address family", and subsequent standards use AF_* everywhere.

Even linux/socket.h specifies as

#define PF_INET AF_INET

Yet, we can say

int socket(int family,int type,int prototype);

Here,family identifies family by address or protocol.Address family identifies a collection of protocol with the SAME ADDRESS FORMAT,while protocol family identifies a collection of protocol having SAME ARCHITECTURE.
Oct 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.