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

Function SetReuseAddressAndPort

library/cpp/testing/unittest/tests_data.h:16–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14// incompatibility: singe SO_REUSEADDR is enough for Linux, but not enough for Darwin
15template <class TSocketType>
16void SetReuseAddressAndPort(const TSocketType& sock) {
17 const int retAddr = SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1);
18 if (retAddr < 0) {
19 ythrow yexception() << "can't set SO_REUSEADDR: " << LastSystemErrorText(-retAddr);
20 }
21
22#ifdef SO_REUSEPORT
23 const int retPort = SetSockOpt(sock, SOL_SOCKET, SO_REUSEPORT, 1);
24 if (retPort < 0) {
25 ythrow yexception() << "can't set SO_REUSEPORT: " << LastSystemErrorText(-retPort);
26 }
27#endif
28}
29
30class TPortManager: public TNonCopyable {
31public:

Callers 1

IsFreePortFunction · 0.85

Calls 2

SetSockOptFunction · 0.85
LastSystemErrorTextFunction · 0.50

Tested by

no test coverage detected