net/AddressInfo: add MakeAddrInfo()
This commit is contained in:
parent
36cad54ccd
commit
50de3a7886
@ -40,6 +40,17 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#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 {
|
class AddressInfo : addrinfo {
|
||||||
/* this class cannot be instantiated, it can only be cast from
|
/* this class cannot be instantiated, it can only be cast from
|
||||||
a struct addrinfo pointer */
|
a struct addrinfo pointer */
|
||||||
|
@ -149,10 +149,6 @@ Resolve(const char *host_and_port, int default_port,
|
|||||||
AddressInfoList
|
AddressInfoList
|
||||||
Resolve(const char *host_port, unsigned default_port, int flags, int socktype)
|
Resolve(const char *host_port, unsigned default_port, int flags, int socktype)
|
||||||
{
|
{
|
||||||
struct addrinfo hints{};
|
const auto hints = MakeAddrInfo(flags, AF_UNSPEC, socktype);
|
||||||
hints.ai_flags = flags;
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
hints.ai_socktype = socktype;
|
|
||||||
|
|
||||||
return Resolve(host_port, default_port, &hints);
|
return Resolve(host_port, default_port, &hints);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user