From: David Nadlinger Subject: ws2_32: getaddrinfo("", ...) on OS X. Message-Id: <4F2AAD98.7080207@klickverbot.at> Date: Thu, 02 Feb 2012 16:36:56 +0100 getaddrinfo() on Windows resolves an empty, but non-null host string to the addresses of all the network interfaces. A workaround for Linux was added in 75be2284, but unfortunately it does not work on OS X, since there, the host part of the machine name alone usually fails to resolve. Tested on OS X 10.7.2, Arch Linux (Kernel 3.1.4, glibc 2.14.1) and Ubuntu Oneric. See http://klickverbot.at/p/getaddrinfo for a detailed comparison of the edge case behavior on the different OSes. --- dlls/ws2_32/socket.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index d3a4590..81e5d1c 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -4802,10 +4802,11 @@ static char *get_hostname(void) char *ret; DWORD size = 0; - GetComputerNameExA( ComputerNamePhysicalDnsHostname, NULL, &size ); + /* FQDN because the host part alone does not resolve on OS X by default. */ + GetComputerNameExA( ComputerNamePhysicalDnsFullyQualified, NULL, &size ); if (GetLastError() != ERROR_MORE_DATA) return NULL; if (!(ret = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL; - if (!GetComputerNameExA( ComputerNamePhysicalDnsHostname, ret, &size )) + if (!GetComputerNameExA( ComputerNamePhysicalDnsFullyQualified, ret, &size )) { HeapFree( GetProcessHeap(), 0, ret ); return NULL;