| 14 | // incompatibility: singe SO_REUSEADDR is enough for Linux, but not enough for Darwin |
| 15 | template <class TSocketType> |
| 16 | void 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 | |
| 30 | class TPortManager: public TNonCopyable { |
| 31 | public: |
no test coverage detected