Yes.
>Especially, if host name does not exist ??
If the DNS servers for the domain don't respond, it may take a while to
time out. Is that what you're asking?
>How does name lookup occur with gethostbyname( )? Is it iterative lookup
>or recursive lookup ??
It's a stub resolver that sends a recursive query to the nameserver.
--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Oh..so gethostbyname( ) sends a recursive query to "named".
Is there any documentation which tells "gethostbyname( )" on Solaris works.
Is there any way we can have timeout facility with "gethostbyname( )"?
Say some config file somewhere ?
If there is no such mechanisms, then there are only two options left with me.
Solution 1
---------------
Call alarm() before gethostbyname( ).
Solution 2
-------------
Fork another thread/process to do get hostbyname( )
And create pipe to the other thread.
And do a poll( ) with timeout on the read end of the pipe.
Thanks for your help/tips in this matter
With regards
Diwakar
Oh..so gethostbyname( ) sends a recursive query to "named".
Is there any documentation which tells "gethostbyname( )" on Solaris works ?
Or for that matter Linux will also do......
Is there any way we can have timeout facility with "gethostbyname( )"?
Say some config file somewhere ?
If there is no such mechanisms, then there are only two options left with me.
Solution 1
---------------
Call alarm() before gethostbyname( ).
Solution 2
-------------
Fork another thread/process to do get hostbyname( )
And create pipe to the other thread.
And do a poll( ) with timeout on the read end of the pipe.
So far as the stub resolver mentioned by you is concerned, here is what "truss" on gethostbyname( ) gave me.
Seems like some Doors (RPC??) call is being made....
----------------------------------------
open("/etc/netconfig", O_RDONLY) = 3
fstat64(3, 0xFFBEA0B8) = 0
ioctl(3, TCGETA, 0xFFBEA044) Err#25 ENOTTY
read(3, " # p r a g m a i d e n".., 8192) = 1239
read(3, 0x000215FC, 8192) = 0
llseek(3, 0, SEEK_CUR) = 1239
llseek(3, 0, SEEK_SET) = 0
read(3, " # p r a g m a i d e n".., 8192) = 1239
read(3, 0x000215FC, 8192) = 0
llseek(3, 0, SEEK_CUR) = 1239
close(3) = 0
open("/dev/udp", O_RDONLY) = 3
ioctl(3, 0xC00C6982, 0xFFBEA60C) = 0
close(3) = 0
open64("/etc/.name_service_door", O_RDONLY) = 3
fcntl(3, F_SETFD, 0x00000001) = 0
door_info(3, 0xFF240788) = 0
door_call(3, 0xFFBE8578) = 0
ioctl(1, TCGETA, 0xFFBE99CC) = 0
-----------------------------------------
Thanks for your help/tips in this matter
With regards
Diwakar
>Is there any way we can have timeout facility with "gethostbyname( )"?
No.
>Solution 1
>---------------
>Call alarm() before gethostbyname( ).
As long as you abor tyour application, you're OK; but you *cannot*
bail out; data sstructures may be corrupted.
>Solution 2
>-------------
>Fork another thread/process to do get hostbyname( )
>And create pipe to the other thread.
>And do a poll( ) with timeout on the read end of the pipe.
You can use a thread and have it hang; then you wait in the original
thread on a condition variable; the other thread will run its
course and die.
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.