AF_INET PF_INET difference - socket programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brunoyalgi
    New Member
    • Oct 2007
    • 1

    AF_INET PF_INET difference - socket programming

    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_f amily = AF_INET;

    socket( PF_INET, SOCK_STREAM, IPPROTO_IP )
    serv_addr.sin_f amily = PF_INET;

    I would like to know where we need to use AF_NET & PF_NET respectively?
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    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.Addres s family identifies a collection of protocol with the SAME ADDRESS FORMAT,while protocol family identifies a collection of protocol having SAME ARCHITECTURE.

    Comment

    Working...