Simplification of switch code

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;

}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.