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

38 Views Asked by At

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?

1

There are 1 best solutions below

2
Sander Steffann On BEST ANSWER

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.