| 248 | } |
| 249 | |
| 250 | std::shared_ptr<ReaderWriter> Socket::accept() const { |
| 251 | std::shared_ptr<Shared> out; |
| 252 | if (shared) { |
| 253 | shared->lock([&](SOCKET socket, const addrinfo*) { |
| 254 | if (socket != InvalidSocket && !errored(socket)) { |
| 255 | init(); |
| 256 | auto accepted = ::accept(socket, 0, 0); |
| 257 | if (accepted != InvalidSocket) { |
| 258 | out = std::make_shared<Shared>(accepted); |
| 259 | out->setOptions(); |
| 260 | } |
| 261 | } |
| 262 | }); |
| 263 | } |
| 264 | return out; |
| 265 | } |
| 266 | |
| 267 | bool Socket::isOpen() const { |
| 268 | if (shared) { |