[cs631apue] dual stack server

Jan Schaumann jschauma at stevens.edu
Tue Nov 24 20:54:56 EST 2020


Since most of you have not set up your http server to
allow for simultaneously accepting connections via
IPv4 and IPv6, I've put together a code example:


The trick here is to use an IPv6 socket, and then to
disable the IPv6_ONLY option on it.  As a result, the
socket will allow IPv4 connections, but the IPv4
connections will become so-called "IPv4-mapped IPv6

There's a few additional considerations when you're
handling a dual-stack server, though many can be
resolved by using a 'struct sockaddr_storage' and then
casting that as needed.

Hope that gets you on the right path...


More information about the cs631apue mailing list