Guest User

Untitled

a guest
Oct 21st, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. enum { max_msg = 1024 };
  2. char read_buffer_[max_msg];
  3.  
  4. void do_read()
  5. {
  6. async_read(m_sock, buffer(read_buffer_),
  7. boost::bind(read_complete,_1,_2),
  8. boost::bind(on_read,_1,_2));
  9. }
  10.  
  11. size_t read_complete(const boost::system::error_code & err, size_t bytes)
  12. {
  13. if ( err) return 0;
  14. bool found = std::find(read_buffer_, read_buffer_ + bytes, 'n') < read_buffer_ + bytes;
  15. // we read one-by-one until we get to enter, no buffering
  16. return found ? 0 : 1;
  17. }
Add Comment
Please, Sign In to add comment