If I wrote a server bound to a wildcard address (INADDR_ANY), how to determine which IP address the client is connected to?
I tried the following code when the after a successful accept call, but it just returned 0.0.0.0.
inet_ntop(AF_INET, &server_address.sin_addr, s, sizeof(s));
As stated in How to determine IP used by client connecting to INADDR_ANY listener socket in C, use getsockname, which gives you the socket which the connection is bound to (on local level).
This is for C, but is applicable for C++ to.