uvw 3.1.0
Loading...
Searching...
No Matches
dns.h
1#ifndef UVW_DNS_INCLUDE_H
2#define UVW_DNS_INCLUDE_H
3
4#include <memory>
5#include <string>
6#include <utility>
7#include <uv.h>
8#include "loop.h"
9#include "request.hpp"
10#include "util.h"
11
12namespace uvw {
13
16 using deleter = void (*)(addrinfo *);
17
18 addr_info_event(std::unique_ptr<addrinfo, deleter> addr);
19
26 std::unique_ptr<addrinfo, deleter> data;
27};
28
31 name_info_event(const char *host, const char *serv);
32
39 const char *hostname;
40
47 const char *service;
48};
49
58class get_addr_info_req final: public request<get_addr_info_req, uv_getaddrinfo_t, addr_info_event> {
59 static void addr_info_callback(uv_getaddrinfo_t *req, int status, addrinfo *res);
60 int node_addr_info(const char *node, const char *service, addrinfo *hints = nullptr);
61 auto node_addr_info_sync(const char *node, const char *service, addrinfo *hints = nullptr);
62
63public:
64 using deleter = void (*)(addrinfo *);
65
66 using request::request;
67
75 int node_addr_info(const std::string &node, addrinfo *hints = nullptr);
76
88 std::pair<bool, std::unique_ptr<addrinfo, deleter>> node_addr_info_sync(const std::string &node, addrinfo *hints = nullptr);
89
97 int service_addr_info(const std::string &service, addrinfo *hints = nullptr);
98
110 std::pair<bool, std::unique_ptr<addrinfo, deleter>> service_addr_info_sync(const std::string &service, addrinfo *hints = nullptr);
111
120 int addr_info(const std::string &node, const std::string &service, addrinfo *hints = nullptr);
121
134 std::pair<bool, std::unique_ptr<addrinfo, deleter>> addr_info_sync(const std::string &node, const std::string &service, addrinfo *hints = nullptr);
135};
136
145class get_name_info_req final: public request<get_name_info_req, uv_getnameinfo_t, name_info_event> {
146 static void name_info_callback(uv_getnameinfo_t *req, int status, const char *hostname, const char *service);
147
148public:
149 using request::request;
150
157 int name_info(const sockaddr &addr, int flags = 0);
158
166 int name_info(const std::string &ip, unsigned int port, int flags = 0);
167
174 int name_info(socket_address addr, int flags = 0);
175
188 std::pair<bool, std::pair<const char *, const char *>> name_info_sync(const sockaddr &addr, int flags = 0);
189
203 std::pair<bool, std::pair<const char *, const char *>> name_info_sync(const std::string &ip, unsigned int port, int flags = 0);
204
217 std::pair<bool, std::pair<const char *, const char *>> name_info_sync(socket_address addr, int flags = 0);
218};
219
220} // namespace uvw
221
222#ifndef UVW_AS_LIB
223# include "dns.cpp"
224#endif
225
226#endif // UVW_DNS_INCLUDE_H
The getaddrinfo request.
Definition: dns.h:58
std::pair< bool, std::unique_ptr< addrinfo, deleter > > node_addr_info_sync(const std::string &node, addrinfo *hints=nullptr)
Sync getaddrinfo.
int node_addr_info(const std::string &node, addrinfo *hints=nullptr)
Async getaddrinfo.
int service_addr_info(const std::string &service, addrinfo *hints=nullptr)
Async getaddrinfo.
int addr_info(const std::string &node, const std::string &service, addrinfo *hints=nullptr)
Async getaddrinfo.
std::pair< bool, std::unique_ptr< addrinfo, deleter > > service_addr_info_sync(const std::string &service, addrinfo *hints=nullptr)
Sync getaddrinfo.
std::pair< bool, std::unique_ptr< addrinfo, deleter > > addr_info_sync(const std::string &node, const std::string &service, addrinfo *hints=nullptr)
Sync getaddrinfo.
The getnameinfo request.
Definition: dns.h:145
std::pair< bool, std::pair< const char *, const char * > > name_info_sync(const sockaddr &addr, int flags=0)
Sync getnameinfo.
int name_info(const std::string &ip, unsigned int port, int flags=0)
Async getnameinfo.
std::pair< bool, std::pair< const char *, const char * > > name_info_sync(socket_address addr, int flags=0)
Sync getnameinfo.
int name_info(const sockaddr &addr, int flags=0)
Async getnameinfo.
int name_info(socket_address addr, int flags=0)
Async getnameinfo.
std::pair< bool, std::pair< const char *, const char * > > name_info_sync(const std::string &ip, unsigned int port, int flags=0)
Sync getnameinfo.
Request base class.
Definition: request.hpp:19
uvw default namespace.
Definition: async.h:8
The addrinfo event.
Definition: dns.h:15
std::unique_ptr< addrinfo, deleter > data
An initialized instance of addrinfo.
Definition: dns.h:26
The nameinfo event.
Definition: dns.h:30
const char * service
A valid service name.
Definition: dns.h:47
const char * hostname
A valid hostname.
Definition: dns.h:39
Address representation.
Definition: util.h:214