| 220 | namespace dap { |
| 221 | |
| 222 | Socket::Socket(const char* address, const char* port) |
| 223 | : shared(Shared::create(address, port)) { |
| 224 | if (shared) { |
| 225 | shared->lock([&](SOCKET socket, const addrinfo* info) { |
| 226 | if (bind(socket, info->ai_addr, (int)info->ai_addrlen) != 0) { |
| 227 | shared.reset(); |
| 228 | return; |
| 229 | } |
| 230 | |
| 231 | if (listen(socket, 0) != 0) { |
| 232 | shared.reset(); |
| 233 | return; |
| 234 | } |
| 235 | }); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | std::shared_ptr<ReaderWriter> Socket::accept() const { |
| 240 | std::shared_ptr<Shared> out; |