How to listen on a socket in the modern IPv6-enabled worldSuppose that you are a fancy modern server program, and you want to listen for both IPv4 and (if available) IPv6 connections. As it happens this is a bit more intricate than you might expect, and it varies between systems. To start with:
Otherwise, you have a choice of two options, because you are on a system that seems to support both IPv4 and IPv6. You either need to create two listening sockets, one for IPv4 only and one for IPv6 only, or you need to create an IPv6 listening socket that is also guaranteed to get IPv4 traffic. Simply binding an IPv6 socket is not enough to insure that you get IPv4 traffic; many systems do not default to dual binding sockets. (Since there are systems that don't support dual binding sockets under any circumstances, such as OpenBSD, using two separate sockets is more portable.) To be able to create separate IPv6 and IPv4 sockets, you need to
explicitly turn on the (I believe but cannot completely confirm that all current IPv6 enabled
Unix systems have Note that you should care about this issue even if your software is Linux specific. While Linux defaults to having dual binding on (which lets you just bind an IPv6 socket and get IPv4 for free), this can be turned off on individual systems and Debian is apparently going to default to having it turned off in their next release. |
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |