Take the 2-minute tour ×  I'm currently working on a UDP socket
application and I need to build in support so that IPV4 and IPV6
connections can send packets to a server.  I was hoping that
someone could help me out and point me in the right direction;
the majority of the documentation that I found was not complete.
It'd also be helpful if you could point out any differences
between Winsock and BSD sockets.  Thanks in advance!
share|improve this question add comment  4 Answers  up vote 41
down vote accepted  The best approach is to create an IPv6
server socket that can also accept IPv4 connections. To do so,
create a regular IPv6 socket, turn off the socket option
IPV6_V6ONLY, bind it to the "any" address, and start receiving.
IPv4 addresses will be presented as IPv6 addresses, in the
IPv4-mapped format.  The major difference across systems is
whether IPV6_V6ONLY is a) available, and b) turned on or off by
default. It is turned off by default on Linux (i.e. allowing
dual-stack sockets without setsockopt), an