The sockets are bound on all interfaces using INADDR_ANY, so getsockname always return 0.0.0.0. The actual address can be obtained from the destination address of the received IP packet using the socket ancillary data.