| 1007 | |
| 1008 | public: |
| 1009 | inline TImpl(const char* host, ui16 port, int flags) |
| 1010 | : Info_(nullptr, TAddrInfoDeleter{}) |
| 1011 | { |
| 1012 | const TString port_st(ToString(port)); |
| 1013 | struct addrinfo hints; |
| 1014 | |
| 1015 | memset(&hints, 0, sizeof(hints)); |
| 1016 | |
| 1017 | hints.ai_flags = flags; |
| 1018 | hints.ai_family = PF_UNSPEC; |
| 1019 | hints.ai_socktype = SOCK_STREAM; |
| 1020 | |
| 1021 | if (!host) { |
| 1022 | hints.ai_flags |= AI_PASSIVE; |
| 1023 | } else { |
| 1024 | if (!Singleton<TLocalNames>()->IsLocalName(host)) { |
| 1025 | hints.ai_flags |= AI_ADDRCONFIG; |
| 1026 | } |
| 1027 | } |
| 1028 | |
| 1029 | struct addrinfo* pai = NULL; |
| 1030 | const int error = getaddrinfo(host, port_st.data(), &hints, &pai); |
| 1031 | |
| 1032 | if (error) { |
| 1033 | TAddrInfoDeleter()(pai); |
| 1034 | ythrow TNetworkResolutionError(error) << ": can not resolve " << host << ":" << port; |
| 1035 | } |
| 1036 | |
| 1037 | Info_.reset(pai); |
| 1038 | } |
| 1039 | |
| 1040 | inline TImpl(const char* path, int flags) |
| 1041 | : Info_(nullptr, TAddrInfoDeleter{/* useFreeAddrInfo = */ false}) |
nothing calls this directly
no test coverage detected