Re: straight-C DNS lookup with timeout?
Re: straight-C DNS lookup with timeout?
- Subject: Re: straight-C DNS lookup with timeout?
- From: Philip George <email@hidden>
- Date: Tue, 31 Dec 2002 06:37:44 -0600
Thanks, Andrew. The code you linked to works perfectly in a 100% C
app. However, if i call it from Obj-C, it fails with signal 10, if and
only if the alarm function gets called.
Anyone know why?
http://www.ugh.net.au/cgi-bin/cvsweb.cgi/~checkout~/code_examples/
timeouts/longjmp.c?rev=1.2
- Philip
On Monday, December 30, 2002, at 05:09 PM, Andrew wrote:
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.
_______________________________________________
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.