| 231 | namespace dap { |
| 232 | |
| 233 | Socket::Socket(const char* address, const char* port) |
| 234 | : shared(Shared::create(address, port)) { |
| 235 | if (shared) { |
| 236 | shared->lock([&](SOCKET socket, const addrinfo* info) { |
| 237 | if (bind(socket, info->ai_addr, (int)info->ai_addrlen) != 0) { |
| 238 | shared.reset(); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | if (listen(socket, 0) != 0) { |
| 243 | shared.reset(); |
| 244 | return; |
| 245 | } |
| 246 | }); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | std::shared_ptr<ReaderWriter> Socket::accept() const { |
| 251 | std::shared_ptr<Shared> out; |