无需“连接”的UDP客户端:net.Dial()在这里无法正常工作

This question already has an answer here:

I'm writing a client for a badly-behaved UDP server: The server replies are sourced from an unpredictable IP address.

Using net.Dial(), I'm able to send a query to the server and provoke the expected response, but because the reply comes from a different IP address, attempts to read it from the net.Conn object never complete.

On the wire, the transaction looks like:

client-ip:client-ephemeral-port -> server-ip:server-well-known-port
surprise-ip:server-well-known-port -> client-ip:client-ephemeral-port

Everything's fine when the server replies from server-ip, rather than from surprise-ip.

Changing the server behavior isn't possible.

I think this means I'm going to need to abandon net.Dial() and get closer to the underlying socket behavior (hopefully in an OS-independent way).

I'm looking for examples of how to accommodate the server behavior, but the various UDP walkthroughs I've found so far seem the rely on 5-tuple "connection" behaviors.

</div>