some equivalent boost::asio::ip::endpoint (easy for using pair ip:port)
| 6 | |
| 7 | // some equivalent boost::asio::ip::endpoint (easy for using pair ip:port) |
| 8 | class TEndpoint { |
| 9 | public: |
| 10 | using TAddrRef = NAddr::IRemoteAddrRef; |
| 11 | |
| 12 | TEndpoint(const TAddrRef& addr); |
| 13 | TEndpoint(); |
| 14 | |
| 15 | inline const TAddrRef& Addr() const noexcept { |
| 16 | return Addr_; |
| 17 | } |
| 18 | inline const sockaddr* SockAddr() const { |
| 19 | return Addr_->Addr(); |
| 20 | } |
| 21 | inline socklen_t SockAddrLen() const { |
| 22 | return Addr_->Len(); |
| 23 | } |
| 24 | |
| 25 | inline bool IsIpV4() const { |
| 26 | return Addr_->Addr()->sa_family == AF_INET; |
| 27 | } |
| 28 | inline bool IsIpV6() const { |
| 29 | return Addr_->Addr()->sa_family == AF_INET6; |
| 30 | } |
| 31 | inline bool IsUnix() const { |
| 32 | return Addr_->Addr()->sa_family == AF_UNIX; |
| 33 | } |
| 34 | |
| 35 | inline TString IpToString() const { |
| 36 | return NAddr::PrintHost(*Addr_); |
| 37 | } |
| 38 | |
| 39 | void SetPort(ui16 port); |
| 40 | ui16 Port() const noexcept; |
| 41 | |
| 42 | size_t Hash() const; |
| 43 | |
| 44 | private: |
| 45 | TAddrRef Addr_; |
| 46 | }; |
| 47 | |
| 48 | template <> |
| 49 | struct THash<TEndpoint> { |
no outgoing calls
no test coverage detected