aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/dns/async.h
blob: 1ec26bc91d75811a1cd5183d91a9759af94cb04b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include "iface.h"

#include <util/network/socket.h>
#include <util/datetime/base.h>
#include <util/generic/ptr.h>

namespace NAsyncDns {
    struct IPoller {
        virtual void OnStateChange(SOCKET s, bool read, bool write) = 0;
    };

    class TAsyncDns {
    public:
        TAsyncDns(IPoller* poller, const TOptions& opts = TOptions());
        ~TAsyncDns();

        void AsyncResolve(const TNameRequest& req);

        TDuration Timeout();
        void ProcessSocket(SOCKET s);
        void ProcessNone();

    private:
        class TImpl;
        THolder<TImpl> I_;
    };

    void CheckAsyncStatus(int status);
    void CheckPartialAsyncStatus(int status);
}