http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html:
gethostbyaddr(), gethostbyname()
Applications are recommended to use the getaddrinfo() and getnameinfo() functions instead of these functions.
The gethostbyaddr() and gethostbyname() functions may return pointers to static data, which may be overwritten by subsequent calls to any of these functions. The suggested replacements do not have this problem and are also IPv6-capable.
This would be one way to making socket.d multithread-safe. But it is quite a major rewrite of socket.d.
The other way is to just use gethostbyname_r (on glibc) or locking (on the other platforms).
I think locking is a relatively expensive operation (OTOH, it is probably cheap compared to
gethostbyname
and friends).btw, are there platforms without
getaddrinfo
andgetnameinfo
?> are there platforms without getaddrinfo and getnameinfo?
Yes, but we would obviously use the gnulib replacement: https://www.gnu.org/software/gnulib/manual/html_node/getnameinfo.html
Diff: