Sockets - Using INADDR_ANY on client side

This is the answer as provided by nos in a comment. If nos comes back and posts it as an answer, I will mark nos' post as the answer and delete this one.

INADDR_ANY is normally defined as 0. That is the IP address 0.0.0.0. RFC 1122 says that means "This host on this network". The linux IP stack seems to just route this to the loopback interface. (e.g. try ping 0.0.0.0 or even just ping 0). I'd say the author made a typo, and should have used INADDR_LOOPBACK.


It seems like your question is not really about "client-side", but about bind vs connect.

INADDR_ANY can be sensibly used with bind on both client and server. Using it with connect() is pointless and should cause a connection failure.