in reply to gethostbyname() and www prefix

I'm no DNS expert, but in your example, baz.com probably has no record pointing to a server for 'baz.com'. There is an MX record that indicates the IP address of the default mail exchanger server, and that's probably what you'll have to query for if you want accurate results.

Using nslookup, you can query the MX record for baz.com with the following command:

nslookup -type=MX baz.com

This should return something like the following:

baz.com preference = 10, mail exchanger = mail.baz.com ... mail.baz.com internet address = xxx.xxx.xxx.xxx

conv