Skip to the content.

G+: Did you know that you can use "*" …

David Coles
Did you know that you can use "*" as a host or service argument to getaddrinfo? I certainly didn't!

In glibc, it's treated as equivalent to a NULL argument. Looks like this behaviour has been around for at least a decade or more. Not in the man page or the POSIX.1-2008 standard, not supported by www.musl-libc.org and not supported on Windows.

I'd would probably recommend relying on said behaviour if you want to have any degree of portability!

(Sadly, I can see the reason behind this - sometimes it's hard to pass an explicit NULL, especially for string arguments. Using "" doesn't work in this case)

Public Git Hosting - glibc.git/blob - sysdeps/posix/getaddrinfo.c