Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 10th, 2020 138 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void EchoServer::HandleClient(std::shared_ptr<tinyfiber::tcp::Socket> socket_ptr) {
  2.     static const size_t kBufSize = 1237;
  3.     char buf[kBufSize];
  4.     std::cout << "Ready to read (server)" << std::endl;
  5.     size_t bytes_read = socket_ptr->ReadSome(asio::buffer(buf, kBufSize));
  6.  
  7.     std::cout << "bytes_ read = " << bytes_read << std::endl;
  8.     socket_ptr->Write(asio::buffer(buf)).ExpectOk();
  9.     SpawnHandler(socket_ptr);
  10. }
  11.  
  12. void EchoServer::SpawnHandler(std::shared_ptr<tinyfiber::tcp::Socket> socket_ptr) {
  13.     auto handler_client = [this, socket_ptr]() {
  14.         this->HandleClient(socket_ptr);
  15.     };
  16.     tinyfiber::Spawn(handler_client);
  17. }
  18.  
  19. void EchoServer::ServeForever() {
  20.     while (true) {
  21.         tinyfiber::tcp::Socket socket = acceptor_.Accept();
  22.         std::cout << "Accepted" << std::endl;
  23.         std::shared_ptr<tinyfiber::tcp::Socket> socket_ptr =
  24.                 std::make_shared<tinyfiber::tcp::Socket>(std::move(socket));
  25.  
  26.         SpawnHandler(socket_ptr);
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top