Go version

all versions since go1.18

Output of go env in your module/workspace:

see above

What did you do?

Create an IPv4 UDP socket listening on 0.0.0.0. Call WriteMsgUDPAddrPort with an IPv4-mapped IPv6 destination address.

What did you see happen?

write udp4 0.0.0.0:48509->[::ffff:192.168.0.162]:20221: address ::ffff:192.168.0.162: non-IPv4 address

What did you expect to see?

The write succeeds, just like WriteMsgUDP.

Back when Go 1.18 was just out, I opened #52264 for sending to IPv4 addresses on IPv6 sockets.

This issue is about the other way around: sending to IPv4-mapped IPv6 addresses on IPv4 sockets. It's less common, as IPv4 UDP sockets are less used compared to dual-stack IPv6 sockets. But it's just as painful, as APIs like net.DefaultResolver.LookupNetIP happily return IPv4-mapped IPv6 addresses.

I'm sending a CL to address it.

Comment From: gabyhelp

Related Issues

Related Code Changes

Related Discussions

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: mknyszek

CC @neild