The server program listens on just a IPv6 socket. Linux kernel will automatically allow this socket to accept both IPv4 and IPv6 connections. Incoming IPv4 address is turned into a special form of IPv6 address. For example, 192.168.5.10 will be shown as "::ffff:192.168.5.10"
The client will automatically detect the format of the client address to determine whether to use IPv4 or IPv6 socket to connect. This is done by the glibc function "getaddrinfo()" internally.
On Linux:
- make
- on one terminal, do ./64server
- on another terminal, do ./64client 127.0.0.1 to connect use IPv4, Or do ./64client ::1 to connect using IPv6