MCPcopy Create free account
hub / github.com/catboost/catboost / TIpAddress

Class TIpAddress

util/network/ip.h:57–119  ·  view source on GitHub ↗

socket address

Source from the content-addressed store, hash-verified

55
56/// socket address
57struct TIpAddress: public sockaddr_in {
58 inline TIpAddress() noexcept {
59 Clear();
60 }
61
62 inline TIpAddress(const sockaddr_in& addr) noexcept
63 : sockaddr_in(addr)
64 , tmp(0)
65 {
66 }
67
68 inline TIpAddress(TIpHost ip, TIpPort port) noexcept {
69 Set(ip, port);
70 }
71
72 inline TIpAddress(TStringBuf ip, TIpPort port) {
73 Set(ResolveHost(ip.data(), ip.size()), port);
74 }
75
76 inline TIpAddress(const char* ip, TIpPort port) {
77 Set(ResolveHost(ip, strlen(ip)), port);
78 }
79
80 inline operator sockaddr*() const noexcept {
81 return (sockaddr*)(sockaddr_in*)this;
82 }
83
84 inline operator socklen_t*() const noexcept {
85 tmp = sizeof(sockaddr_in);
86
87 return (socklen_t*)&tmp;
88 }
89
90 inline operator socklen_t() const noexcept {
91 tmp = sizeof(sockaddr_in);
92
93 return tmp;
94 }
95
96 inline void Clear() noexcept {
97 Zero((sockaddr_in&)(*this));
98 }
99
100 inline void Set(TIpHost ip, TIpPort port) noexcept {
101 Clear();
102
103 sin_family = AF_INET;
104 sin_addr.s_addr = ip;
105 sin_port = HostToInet(port);
106 }
107
108 inline TIpHost Host() const noexcept {
109 return sin_addr.s_addr;
110 }
111
112 inline TIpPort Port() const noexcept {
113 return InetToHost(sin_port);
114 }

Callers 1

TEndpointMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected