Where I can find examples how to program name server queries? I'm writing smtp client, which will accept internet addresess like firstname.lastname@example.org. I need to query mail server for company.com. I can do this by executing nslookup and piping result to file, but I'm looking more sophisticated solution. Any suggestions?