socketsipv6ipv4

Can dual-stack sockets bind to specific IPv6 and IPv4 addresses?


Question is in the title. Is it possible that a dual-stack socket binds to one specific IPv6 address and another specific IPv4 address? Or do dual-stack sockets always need to bind to ::/0.0.0.0?


Solution

  • To listen on specific addresses you always need to create separate sockets and listen on all of them.

    PS: Binding to :: usually gives you a dual-stack socket that listens on all IPv4 and IPv6 addresses, but not always. It depends on the setting of the IPV6_V6ONLY socket option.