Using Python on Linux: I have a TCPSocket server that I would like to listen on eth0, and no other interfaces. If eth0 has no address, the socket should not listen at all.
I can bind to the IP address associated with eth0, but if that address changes, my socket will no longer receive connections. There appears to be no simple way to receive notifications of IP address changes.
I could poll the IP address of eth0, and bind the socket to the new address when it changes. Is there a better way of implementing this?
I explored SO_BINDTODEVICE but this requires root privileges.