Specifically sin_addr seems to be located on different memory locations for IPv4 and IPv6 socket addressed. This results in weirdness:
#include
No, for ipv6 you need to use
in6_addr // is used to store the 128-bit network address
and
sockaddr_in6
Details can be referenced here
For writing code which supports dual stack i.e. ipv4 and 6 along use this