diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-21 08:26:12 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-21 08:26:12 +0200 |
commit | 4a1e885c0a0e63ef4a8408b33e1de818a0cdb39f (patch) | |
tree | 28934864d5b15f6a12815e14a38dcc535f548073 /src/event | |
parent | eee91aa4eadd5dae7438e3c7abfa32c546290d6b (diff) |
net/Resolver: replace with more advanced implementation
The new implementation is copied from another project and is
BSD-licensed. It is exception-safe and can parse IPv6 scope ids with
interface names.
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/ServerSocket.cxx | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index 67919b913..e2a97f5cb 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -27,6 +27,7 @@ #include "net/SocketError.hxx" #include "net/UniqueSocketDescriptor.hxx" #include "net/Resolver.hxx" +#include "net/AddressInfo.hxx" #include "net/ToString.hxx" #include "event/SocketMonitor.hxx" #include "fs/AllocatedPath.hxx" @@ -369,12 +370,9 @@ void ServerSocket::AddHost(const char *hostname, unsigned port) { #ifdef HAVE_TCP - struct addrinfo *ai = resolve_host_port(hostname, port, - AI_PASSIVE, SOCK_STREAM); - AtScopeExit(ai) { freeaddrinfo(ai); }; - - for (const struct addrinfo *i = ai; i != nullptr; i = i->ai_next) - AddAddress(SocketAddress(i->ai_addr, i->ai_addrlen)); + for (const auto &i : Resolve(hostname, port, + AI_PASSIVE, SOCK_STREAM)) + AddAddress(i); ++next_serial; #else /* HAVE_TCP */ |