Hi people,

I am trying to understand the process of translating ipv4 code to support ipv6 protocol type. But it is very difficult for me to undersrand the following. If I have ipv4 code

struct sockaddr_in saddr;
bzero((char *) &saddr, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons((u_short) service);
saddr.sin_addr.s_addr = INADDR_ANY;

to make this structure to support pure ipv6 is necessary change sockaddr_in to sockaddr_in6, sin_family=AF_INET to sin6_family=AF_INET6, sin_addr to sin6_addr and , INADDR_ANY to in6addr_any, and get ipv6 compatible structure. But if we want to make address family independet application then we have to use sockaddr_storage which can storage all necessary for that purpose. I
cannot understand how to above code rewrite to be address familly independent. About sockaddr_storage structure you can read at web location


Is there is someone who already did something similar and is willing to share her/his knowledge it will be highly valuated.

Thank you in advance