Using gethostbyname_r instead of gethostbyname in std.socket

MWumpusZ via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 10 04:12:45 PDT 2016


On Saturday, 8 October 2016 at 13:46:28 UTC, Jakob Ovrum wrote:
...
> The doc for InternetAddress does say it uses InternetHost 
> internally, and the docs do recommend getAddress over using 
> Internet{Host, Address} directly,

I have no idea why we don't use std.socket.getAddress; I'll look 
into that.  If switching over is viable (which I imagine it is) 
and sufficient, then that sounds like a great solution short term.

> but maybe InternetHost.getHostByName should use getAddress 
> internally to benefit from getaddrinfo.

Sounds good :)  I can't comment on what wider impact that might 
have though.

> If not, it should probably at least warn about not being 
> reentrant.

It is "kind of" reentrant - it has synchronisation around the 
gethostbyname call.  Things fall apart when gethostbyname is 
accessed directly, e.g. by a third party library, as is the case 
in our application.



More information about the Digitalmars-d mailing list