| 89 | class dap::Socket::Shared : public dap::ReaderWriter { |
| 90 | public: |
| 91 | static std::shared_ptr<Shared> create(const char* address, const char* port) { |
| 92 | init(); |
| 93 | |
| 94 | addrinfo hints = {}; |
| 95 | hints.ai_family = AF_INET; |
| 96 | hints.ai_socktype = SOCK_STREAM; |
| 97 | hints.ai_protocol = IPPROTO_TCP; |
| 98 | hints.ai_flags = AI_PASSIVE; |
| 99 | |
| 100 | addrinfo* info = nullptr; |
| 101 | getaddrinfo(address, port, &hints, &info); |
| 102 | |
| 103 | if (info) { |
| 104 | auto socket = |
| 105 | ::socket(info->ai_family, info->ai_socktype, info->ai_protocol); |
| 106 | auto out = std::make_shared<Shared>(info, socket); |
| 107 | out->setOptions(); |
| 108 | return out; |
| 109 | } |
| 110 | |
| 111 | term(); |
| 112 | return nullptr; |
| 113 | } |
| 114 | |
| 115 | Shared(SOCKET socket) : info(nullptr), s(socket) {} |
| 116 | Shared(addrinfo* info, SOCKET socket) : info(info), s(socket) {} |
nothing calls this directly
no test coverage detected