This is probably the simplest solution to the switch code I discussed yesterday:
union sockaddress{
struct sockaddr addr;
struct sockaddr_in in;
struct sockaddr_in6 in6;
} sockaddress;
union sockaddress sa;
To find the type:
switch (sa.addr. sa_family){
case AF_INET:
…
case AF_INET6;
…
}