[SDL] SDLNetResolveIP coded

Mattias Engdegård f91-men at nada.kth.se
Fri Apr 14 07:13:49 PDT 2000


>/* Resolve an ip address to a host name in canonical form.
>   If the ip couldn't be resolved, this function returns NULL,
>   otherwise a pointer to a static buffer containing the hostname
>   is returned.  Note that this function is not thread-safe.

No, you return a malloc (leaking memory) if the reverse lookup fail.
Better return a pointer to static storage.

It would be handy to have a thread-safe or (better) asynch version
of this call, since that is tricky to do portably. If the platform
supports getXbyY_r(), you can have it thread safe and run the lookup
in a thread; otherwise, the usual procedure is to fork and pass the
result in a pipe.

(Why doesn't POSIX have an asynch DNS lookups? Even Windows and MacOS can
do that!)




More information about the SDL mailing list