Dns.GetHostAddresses()

  • Thread starter Thread starter Justin Rich
  • Start date Start date
J

Justin Rich

so im pulling a list of computer names from the AD.. and then for each name
im doing a DNS lookup to get the IP... the problem is that apparently not
all of the names in the AD are in DNS... which is expected, and fine.. the
problem is that if the host isnt found the method pukes... and im not really
sure why this is... i guess i can toss a try/catch around it.. but is there
some better way to handle this?

Thanks
Justin
 
Justin said:
so im pulling a list of computer names from the AD.. and then for each name
im doing a DNS lookup to get the IP... the problem is that apparently not
all of the names in the AD are in DNS... which is expected, and fine.. the
problem is that if the host isnt found the method pukes... and im not really
sure why this is... i guess i can toss a try/catch around it.. but is there
some better way to handle this?

The normal way to handle this would be try/catching the GetHostAddresses
call.

Chris.
 
so im pulling a list of computer names from the AD.. and then for each name
im doing a DNS lookup to get the IP... the problem is that apparently not
all of the names in the AD are in DNS... which is expected, and fine.. the
problem is that if the host isnt found the method pukes... and im not really
sure why this is... i guess i can toss a try/catch around it.. but is there
some better way to handle this?

The underlying WSA functions have errors that are mapped into
SocketExceptions. Due to the fact that one of the underlying errors
of a gethostbyname function (which is ultimately the WSA function
called) is WSA_HOST_NOT_FOUND, you will get a SocketException whenever
this error occurs. This is the behavior, so wrap your call with a try/
catch SocketException block.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top