fork download
  1. server.start([&] (Socket socket) {
  2. std::async(std::launch::async, [&] (Socket sock) {
  3. socketstream stream(std::move(sock));
  4. {
  5. std::lock_guard<decltype(mutex)> lock(mutex);
  6. streams.insert(&stream);
  7. }
  8.  
  9. std::string line;
  10. while (std::getline(stream, line)) {
  11. std::cout << line << '\n';
  12. std::lock_guard<decltype(*mutex)> lock(*mutex);
  13. for (auto* sockstream : streams) {
  14. if (sockstream == &stream) continue;
  15. *sockstream << line;
  16. }
  17. }
  18.  
  19. streams.erase(&stream);
  20. }, std::move(socket));
  21. });
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty