21 #ifndef XAPIAN_INCLUDED_RESOLVER_H 22 #define XAPIAN_INCLUDED_RESOLVER_H 33 struct addrinfo* result = NULL;
50 struct addrinfo* old_p = p;
64 Resolver(
const std::string& host,
int port,
int flags = 0) {
96 if (host !=
"::1" && host !=
"127.0.0.1" && host !=
"localhost") {
97 flags |= AI_ADDRCONFIG;
101 #ifdef AI_NUMERICSERV 102 flags |= AI_NUMERICSERV;
105 struct addrinfo hints;
106 std::memset(&hints, 0,
sizeof(
struct addrinfo));
107 hints.ai_family = AF_INET;
108 hints.ai_socktype = SOCK_STREAM;
109 hints.ai_flags = flags;
110 hints.ai_protocol = 0;
112 const char *
node = host.empty() ? NULL : host.c_str();
113 int r = getaddrinfo(node,
str(port).c_str(), &hints, &result);
121 if (result) freeaddrinfo(result);
133 #endif // XAPIAN_INCLUDED_RESOLVER_H
bool operator==(const const_iterator &o) const
include <sys/socket.h> with portability workarounds.
Convert types to std::string.
include <netdb.h>, with portability workarounds.
const_iterator operator++(int)
Hierarchy of classes which Xapian can throw as exceptions.
string str(int value)
Convert int to std::string.
const_iterator end() const
const_iterator(struct addrinfo *p_)
Indicates a problem communicating with a remote database.
const_iterator begin() const
bool operator!=(const const_iterator &o) const
struct addrinfo & operator*() const
Resolver(const std::string &host, int port, int flags=0)