Re: gethostbyname() issue
Re: gethostbyname() issue
- Subject: Re: gethostbyname() issue
- From: Edward Fink <email@hidden>
- Date: Fri, 1 Nov 2002 14:19:57 -0500
I do check for NULL and unfortunately it isn't NULL. In fact all other
values in the hostent returned are set to some value. When I check the
h_addr value however that's when the crash occurs. How would I account
for a CNAME record pointing to itself?
Thanks.
On Friday, November 1, 2002, at 02:02 PM, Glenn Anderson wrote:
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.
_______________________________________________
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.