net_test.h 721 B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include "udp_socket.h"
  3. namespace NNetliba {
  4. struct TUdpAddress;
  5. // needed to limit simultaneous port testers to avoid limit on open handles count
  6. extern TAtomic ActivePortTestersCount;
  7. // need separate socket for each destination
  8. // FreeBSD can not return port unreachable error for unconnected socket
  9. class TPortUnreachableTester: public TThrRefBase {
  10. TNetSocket s;
  11. float TimePassed;
  12. bool ConnectOk;
  13. ~TPortUnreachableTester() override;
  14. public:
  15. TPortUnreachableTester();
  16. bool IsValid() const {
  17. return s.IsValid();
  18. }
  19. void Connect(const TUdpAddress& addr);
  20. bool Test(float deltaT);
  21. };
  22. }