aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-03 13:23:03 +0100
committerMax Kellermann <max@duempel.org>2009-01-03 13:23:03 +0100
commit019bca247527e0fdd04532543d835742acf5a833 (patch)
treeb08bf78bf219876ead1c75c0b42e6817beba0e09 /src
parentfa9b5fd10b19bc651f4c52555764a9cd4c2c7de1 (diff)
downloadmpd-019bca247527e0fdd04532543d835742acf5a833.tar.gz
mpd-019bca247527e0fdd04532543d835742acf5a833.tar.xz
mpd-019bca247527e0fdd04532543d835742acf5a833.zip
listen: use gethostbyname() on WIN32
WIN32 has no getaddrinfo(). Fall back to gethostbyname().
Diffstat (limited to 'src')
-rw-r--r--src/listen.c18
1 files changed, 18 insertions, 0 deletions
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 */