Clarification on .v6 Listener Accepting Both IPv4 and IPv6 Traffic vs NWListener with .any

Hello everyone,

I have a question regarding the behavior of network listeners in my application. Here's the scenario I'm seeing:

  1. When I open a .v6 listener, it accepts both IPv4 and IPv6 traffic. However, when I run the netstat -tln command, the socket is shown as udp6.
  2. When I open a NWListener with the IP version set to .any, I receive both IPv4 and IPv6 traffic on the listener. In this case, running netstat -tln shows a udp46 socket.

My understanding is that if I create a socket with .v6, it should only accept IPv6 connections, not both IPv4 and IPv6. However, the .v6 listener appears to be accepting both types of traffic, which is causing some confusion.

Additionally, I am seeking to understand the difference between a udp6 socket and a udp46 socket, and also the difference between sockets created using .v6 and .any. What exactly does udp46 represent, and how is it different from udp6 in terms of accepting traffic?

Is this expected behavior, or is there something I am missing in how the listeners are set up?

Looking forward to hearing your insights!

Answered by DTS Engineer in 817412022
What exactly does udp46 represent, and how is it different from udp6 in terms of accepting traffic?

Let’s start with tcp46, because that’s easier to explain (-: This is a standard BSD Sockets-y way to have a single listening socket that supports both protocol versions. Connections made using IPv6 work in the usual way. Connections made using IPv4 appear to come from an IPv6 remote peer but the IPv4 address is mapped into the IPv6 space. See IPv4-mapped IPv6 address here.

udp46 is similar because it’s harder to talk about because the protocol itself doesn’t support connections.

If you open a .v6 listener and it accepts IPv4 connections, that’d be a bug IMO. I encourage you to file it as such. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

What exactly does udp46 represent, and how is it different from udp6 in terms of accepting traffic?

Let’s start with tcp46, because that’s easier to explain (-: This is a standard BSD Sockets-y way to have a single listening socket that supports both protocol versions. Connections made using IPv6 work in the usual way. Connections made using IPv4 appear to come from an IPv6 remote peer but the IPv4 address is mapped into the IPv6 space. See IPv4-mapped IPv6 address here.

udp46 is similar because it’s harder to talk about because the protocol itself doesn’t support connections.

If you open a .v6 listener and it accepts IPv4 connections, that’d be a bug IMO. I encourage you to file it as such. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Clarification on .v6 Listener Accepting Both IPv4 and IPv6 Traffic vs NWListener with .any
 
 
Q