21 #ifndef XAPIAN_INCLUDED_RESOLVER_H 22 #define XAPIAN_INCLUDED_RESOLVER_H 34 struct addrinfo* result = NULL;
51 struct addrinfo* old_p = p;
65 Resolver(
const std::string& host,
int port,
int flags = 0) {
97 if (host !=
"::1" && host !=
"127.0.0.1" && host !=
"localhost") {
98 flags |= AI_ADDRCONFIG;
102 #ifdef AI_NUMERICSERV 103 flags |= AI_NUMERICSERV;
106 struct addrinfo hints;
107 std::memset(&hints, 0,
sizeof(
struct addrinfo));
108 hints.ai_family = AF_INET;
109 hints.ai_socktype = SOCK_STREAM;
110 hints.ai_flags = flags;
111 hints.ai_protocol = 0;
113 const char *
node = host.empty() ? NULL : host.c_str();
114 int r = getaddrinfo(node,
str(port).c_str(), &hints, &result);
122 if (result) freeaddrinfo(result);
134 #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)