struct sockaddr {
unsigned short sa_family; // address family, AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};
In this structure what exactly is the meaning address family depicted by sa_family
?
Does it mean that protocols like TCP/UDP have "addresses"? Well, the protocols can be identification numbers not addresses, I think.
Anyway, if yes, then on what basis have their families been divided?
The format and size of the address is usually protocol specific.
sockaddr
is used as the base of a set of address structures that act like a discriminated union, see the Beej guide to networking. You generally look at the sa_family
and then cast to the appropriate address family's specific address structure.
TCP and UDP do not have addresses specific to them as such, rather the IP level has different sizes of address for IPv4 and IPv6.
See also: