Re: straight-C DNS lookup with timeout?
Re: straight-C DNS lookup with timeout?
- Subject: Re: straight-C DNS lookup with timeout?
- From: Andrew <email@hidden>
- Date: Tue, 31 Dec 2002 10:09:40 +1100 (EST)
On Mon, 30 Dec 2002, Philip George wrote:
>
I'm using gethostbyaddr() right now, but I'm open for any straight-C
>
suggestions. I must set a quicker timeout on the lookup. The default
>
timeout is way too long for gethostbyaddr().
You can use signals to implement your own timeout mechanism. There is an
example at
http://www.ugh.net.au/cgi-bin/cvsweb.cgi/~checkout~/code_examples/timeouts/longjmp.c?rev=1.2
of timing out read(2) but the principle is the same.
You situation may be complicated a bit by your use of threads (you will
have to gurantee the signal is received by the right thread by blocking it
elsewhere). Also any function that maintains its own internal state may
behave strangely if yoiu call it after having effectively killed off a
previous invocation.
You might want to look at getnameinfo as an alterantive to gethostbyaddr
however so you can also use IPv6 - its not thread safe though so you would
still need to do a bit of work.
Perhaps you should grab one of the asynchronous DNS look up libraries and
use that instead (or roll your own)?
Andrew
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.