Subject: gethostbyname & gethostbyaddr in libc thread-safe yet?
To: None <tech-net@NetBSD.org>
From: Alicia da Conceicao <alicia@engine.ca>
List: tech-net
Date: 05/25/2004 07:28:43
Sorry if this is a FAQ, but I was wondering if DNS routines
"gethostbyname" & "gethostbyaddr" in libc have been made thread-
safe yet?

I understand that these routines blocks, and return a static
"hostent" structure, but this is not an issue as long as
different threads receive different static data and don't
clobber or block other threads.  Microsoft's VC++/eVC++
"gethostbyname" & "gethostbyaddr" routines, and Solaris's
"gethostbyname_r" & "gethostbyaddr_r", do this and hence can
be considered thread-safe.  I require some type of portable
(cross-platform & multi-OS) thread-safe method of resolving
domain names and IP addresses in an application.

Back in 1998, Perry mentioned:
> There is a project under way to try to make our libc thread
> safe and add kernel support for threading.
<http://mail-index.netbsd.org/current-users/1998/07/24/0007.html>

But I don't know if this was successful.  Was it, or does anyone
know if it will be completed anytime soon?  If not, does anyone
have any suggestions on thread safe alternatives to the
"gethostbyname" & "gethostbyaddr" routines, which can be
considered cross-platform & multi-OS and does not require
writing a DNS client resolver stack from scratch?

Thank you in advance.
Alicia.