Background:
I\'m writing a daemon that makes outgoing TCP/IP connections. It will be running on machines with multiple (non-loopback) IP addresses.
are you sure you are using gethostname()/gethostbyname() correctly? check out here, the only problem I see with doing this is that it's possible that a domain name has multiple ip addresses mapped to it. If that's the case then there's no way of knowing what the ip address belonging to the local machine is