aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-20 20:52:49 +0200
committerMax Kellermann <max@duempel.org>2011-09-20 21:15:22 +0200
commita3f7947ad2e987aaa06a81fe564871448aeb12d2 (patch)
treefc7b5b33a2e9fee14e79ed67ef28947ecd423fc2 /src
parent7d9d459ac2c71e0b3598ed0f606cd2d550853838 (diff)
downloadmpd-a3f7947ad2e987aaa06a81fe564871448aeb12d2.tar.gz
mpd-a3f7947ad2e987aaa06a81fe564871448aeb12d2.tar.xz
mpd-a3f7947ad2e987aaa06a81fe564871448aeb12d2.zip
server_socket: use resolve_host_port() instead of getaddrinfo()
Allow port specification in "bind_to_address" settings.
Diffstat (limited to 'src')
-rw-r--r--src/server_socket.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/server_socket.c b/src/server_socket.c
index dba549bfc..998786d7b 100644
--- a/src/server_socket.c
+++ b/src/server_socket.c
@@ -380,24 +380,11 @@ server_socket_add_host(struct server_socket *ss, const char *hostname,
unsigned port, GError **error_r)
{
#ifdef HAVE_TCP
- struct addrinfo hints;
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_PASSIVE;
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
-
- char service[20];
- g_snprintf(service, sizeof(service), "%u", port);
-
- struct addrinfo *ai;
- int ret = getaddrinfo(hostname, service, &hints, &ai);
- if (ret != 0) {
- g_set_error(error_r, server_socket_quark(), ret,
- "Failed to look up host \"%s\": %s",
- hostname, gai_strerror(ret));
+ struct addrinfo *ai = resolve_host_port(hostname, port,
+ AI_PASSIVE, SOCK_STREAM,
+ error_r);
+ if (ai == NULL)
return false;
- }
for (const struct addrinfo *i = ai; i != NULL; i = i->ai_next)
server_socket_add_address(ss, i->ai_addr, i->ai_addrlen);