I have an asynchronous UDP server class with a socket bound on IPAddress.Any, and I\'d like to know which IPAddress the received packet was sent to (...or received on). It
One way you'll get an address from that socket would be to connect it to the sender. Once you do that, you'll be able to get the local address (or at least, one routable to the sender), however, you'll only be able to receive messages from the connected endpoint.
To unconnect, you'll need to use connect again, this time specifying an address with a family of AF_UNSPEC
. Unfortunately, I don't know how this would be achieved in C#.
(Disclaimer: I've never written a line of C#, this applies to Winsock in general)