INADDR_ANY tells the socket to bind to all interfaces. If you pass a specific IP, then it will bind to the specified interface. To enumerate through the interfaces, you can use:
If you want to get your assigned/existing ip manually, AFAIK the only way is to parse the data returned by "ifconfig" (which is a system, not a C, command). That is awkward, which implies to me that INADDR_ANY is the proper solution.
His code should work. inet_addr does the same thing as inet_aton().
It should not work. The address is a big endian (network byte order) number, not a string, which is the purpose of inet_aton and inet_ntoa.