Creating an IPV6 Socket

I use dual stack mode to support IPV4 and IPV6. If I create an IPV6 socket and listen to it, will it accept a connection from an IPv4 socket as well?

+3
source share
3 answers

Yes, unless the operating system is configured differently, for example. net.ipv6.bindv6only=1on Linux, or you set the socket option IPV6_V6ONLY.

+3
source

Only if the system has dual-stack . Most modern systems do, but older versions of Windows and OpenBSD do not. You should not rely on this, though. Get the IPV6_V6ONLY socket option value, and if it is zero, you will need to open a second socket for IPv4.

IPv4 ::ffff:[IPv4 address]; ::ffff:127.0.0.1 ( ::ffff:7f00:1, , ).

+2

According to Microsoft , by default, even in dual-stack mode, the IPV6_V6ONLY parameter is set to false - but you can enable it by calling setsockopt (2). FWIW, "Old versions" of Windows (single-stack) include the still widely used Windows XP (something more than Vista).

So, if you're on Windows, you should try disabling IPV6_V6ONLY and see if it succeeds. I don't know if this is a good answer for other implementations of the same stack or not.

+1
source

All Articles