aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/netliba/v6/net_test.h
blob: cfff7409f53cc5b227b41ffbc748b895af6b2e7e (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
#pragma once

#include "udp_socket.h"

namespace NNetliba {
    struct TUdpAddress;

    // needed to limit simultaneous port testers to avoid limit on open handles count
    extern TAtomic ActivePortTestersCount;

    // need separate socket for each destination
    // FreeBSD can not return port unreachable error for unconnected socket
    class TPortUnreachableTester: public TThrRefBase {
        TNetSocket s;
        float TimePassed;
        bool ConnectOk;

        ~TPortUnreachableTester() override;

    public:
        TPortUnreachableTester();
        bool IsValid() const {
            return s.IsValid();
        }
        void Connect(const TUdpAddress& addr);
        bool Test(float deltaT);
    };
}