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 /test | |
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 'test')
-rw-r--r-- | test/run_resolver.cxx | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/test/run_resolver.cxx b/test/run_resolver.cxx index 681d64445..8e712301a 100644 --- a/test/run_resolver.cxx +++ b/test/run_resolver.cxx @@ -19,20 +19,13 @@ #include "config.h" #include "net/Resolver.hxx" +#include "net/AddressInfo.hxx" #include "net/ToString.hxx" #include "net/SocketAddress.hxx" #include "Log.hxx" #include <exception> -#ifdef _WIN32 -#include <ws2tcpip.h> -#include <winsock.h> -#else -#include <sys/socket.h> -#include <netdb.h> -#endif - #include <stdio.h> #include <stdlib.h> @@ -43,15 +36,10 @@ try { return EXIT_FAILURE; } - struct addrinfo *ai = - resolve_host_port(argv[1], 80, AI_PASSIVE, SOCK_STREAM); - - for (const struct addrinfo *i = ai; i != NULL; i = i->ai_next) { - const auto s = ToString({i->ai_addr, i->ai_addrlen}); - printf("%s\n", s.c_str()); + for (const auto &i : Resolve(argv[1], 80, AI_PASSIVE, SOCK_STREAM)) { + printf("%s\n", ToString(i).c_str()); } - freeaddrinfo(ai); return EXIT_SUCCESS; } catch (...) { LogError(std::current_exception()); |