Re: gethostbyname() issue
Re: gethostbyname() issue
- Subject: Re: gethostbyname() issue
- From: Glenn Anderson <email@hidden>
- Date: Sat, 2 Nov 2002 08:02:52 +1300
I am having a problem with the "hostent" returned via function
gethostbyname(). Most of the time it works perfectly and...for a
while...I was unable to recreate the problem until I found a hostname
that consistently recreates the issue. Currently...if I use host
"irc.hagabard.com" in gethostbyname()....and then try to reference
h_addr my app crashes.
The crash can be recreated using something like this:
struct hostent *h;
h = gethostbyname("irc.hagabard.com");
then reference h->h_addr anyway you wish and the app should crash.
Anyone know what is happening here and how to fix?
gethostbyname will return NULL if there is an error, you should check
for that. irc.hagabard.com does not have an A record in the DNS,
which will be why you are getting an error. If you are checking for
NULL, then I would guess the problem is some sort of bug due to the
fact that irc.hagabard.com has a CNAME record that points to itself.
I have temporarily
worked around this issue by using NSHost...but for some reason NSHost
is horribly slow for me...taking up to 3 minutes to run?
If it is taking 3 minutes to run for irc.hagabard.com that could also
be a bug related to irc.hagabard.com having a CNAME record that
points to itself. I found DNR performance in general to be
unacceptable under OS X so ended up writing my own DNR.
Glenn.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.