Advertisement
Guest User

One await

a guest
Jan 3rd, 2015
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. std::future<ptrdiff_t> tcp_reader(int total)
  2. {
  3.     char bug[64 * 1024];
  4.     ptrdiff_t result = 0;
  5.  
  6.     auto conn = await Tcp::Connect("127.0.0.1", 1337);
  7.     do
  8.     {
  9.         auto bytesRead = conn.Read(buf, sizeof(buf)).get();
  10.         total -= bytesRead;
  11.         result += std::count(buf, buf + bytesRead, 'c');
  12.     }
  13.     while (total > 0);
  14.     return result;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement