| 264 | } |
| 265 | |
| 266 | std::shared_ptr<ReaderWriter> Socket::accept() const { |
| 267 | std::shared_ptr<Shared> out; |
| 268 | if (shared) { |
| 269 | shared->lock([&](SOCKET socket, const addrinfo*) { |
| 270 | if (socket != InvalidSocket && !errored(socket)) { |
| 271 | init(); |
| 272 | auto accepted = ::accept(socket, 0, 0); |
| 273 | if (accepted != InvalidSocket) { |
| 274 | out = std::make_shared<Shared>(accepted); |
| 275 | out->setOptions(); |
| 276 | } |
| 277 | } |
| 278 | }); |
| 279 | } |
| 280 | return out; |
| 281 | } |
| 282 | |
| 283 | bool Socket::isOpen() const { |
| 284 | if (shared) { |