From 019bca247527e0fdd04532543d835742acf5a833 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 3 Jan 2009 13:23:03 +0100 Subject: listen: use gethostbyname() on WIN32 WIN32 has no getaddrinfo(). Fall back to gethostbyname(). --- src/listen.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/listen.c b/src/listen.c index 94c965f28..a59a6aa02 100644 --- a/src/listen.c +++ b/src/listen.c @@ -174,6 +174,7 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port, ConfigParam * param) #endif /* HAVE_UN */ } else { #ifdef HAVE_TCP +#ifndef WIN32 struct addrinfo hints, *ai, *i; char service[20]; int ret; @@ -202,6 +203,23 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port, ConfigParam * param) BINDERROR(); freeaddrinfo(ai); +#else /* WIN32 */ + const struct hostent *he; + + g_debug("binding to address for %s", param->value); + + he = gethostbyname(param->value); + if (he == NULL) + g_error("can't lookup host \"%s\" at line %i", + param->value, param->line); + + if (he->h_addrtype != AF_INET) + g_error("IPv4 address expected for host \"%s\" at line %i", + param->value, param->line); + + if (establishListen(AF_INET, he->h_addr, he->h_length) < 0) + BINDERROR(); +#endif /* !WIN32 */ #else /* HAVE_TCP */ g_error("TCP support is disabled"); #endif /* HAVE_TCP */ -- cgit v1.2.3