Commit 50de3a78 authored by Max Kellermann's avatar Max Kellermann Committed by Max Kellermann

net/AddressInfo: add MakeAddrInfo()

parent 36cad54c
......@@ -40,6 +40,17 @@
#include <netdb.h>
#endif
constexpr struct addrinfo
MakeAddrInfo(int flags, int family, int socktype, int protocol=0) noexcept
{
struct addrinfo ai{};
ai.ai_flags = flags;
ai.ai_family = family;
ai.ai_socktype = socktype;
ai.ai_protocol = protocol;
return ai;
}
class AddressInfo : addrinfo {
/* this class cannot be instantiated, it can only be cast from
a struct addrinfo pointer */
......
......@@ -149,10 +149,6 @@ Resolve(const char *host_and_port, int default_port,
AddressInfoList
Resolve(const char *host_port, unsigned default_port, int flags, int socktype)
{
struct addrinfo hints{};
hints.ai_flags = flags;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = socktype;
const auto hints = MakeAddrInfo(flags, AF_UNSPEC, socktype);
return Resolve(host_port, default_port, &hints);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment