5
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6
* See COPYRIGHT.txt for details.
9
#ifndef DENA_AUTO_ADDRINFO_HPP
10
#define DENA_AUTO_ADDRINFO_HPP
12
#include <sys/types.h>
13
#include <sys/socket.h>
20
struct auto_addrinfo : private noncopyable {
21
auto_addrinfo() : addr(0) { }
25
void reset(addrinfo *a = 0) {
31
const addrinfo *get() const { return addr; }
32
int resolve(const char *node, const char *service, int flags = 0,
33
int family = AF_UNSPEC, int socktype = SOCK_STREAM, int protocol = 0) {
36
hints.ai_flags = flags;
37
hints.ai_family = family;
38
hints.ai_socktype = socktype;
39
hints.ai_protocol = protocol;
40
return getaddrinfo(node, service, &hints, &addr);