1

I can't really understand the use described in asio documentation for socket::async_wait. It says:

Asynchronously wait for the socket to become ready to read, ready to write, or to have pending error conditions.

What does pending error conditions apply to? Does the error received within async_send/async_receive count? If it does, will I receive the error twice: as an argument for async_receive and as an argument for async_wait? And in which order?

So far I thought that I would receive an error with socket::async_wait from the server on its shutdown, but I didn't receive anything...

Sergey Kolesnik
  • 3,009
  • 1
  • 8
  • 28
  • Interesting question. I've ran into this before, and remember that @DavidSchwartz had linked an insightful post. Sadly those comments have disappeared. But maybe the very similar question helps you: https://stackoverflow.com/a/59506756/85371 – sehe Jun 06 '21 at 09:56
  • I've since come across the notion of SO_KEEPALIVE, which may or may not be instrumental to your solution – sehe Jun 06 '21 at 09:57
  • @sehe I've found out that one way to get if a server has been shut down is to invoke `asyn_receive` and wait for `eof`. But in that case I never receive an error with `async_wait`. I think there's something in the description, that should be taken into an account. It waits for **the socket** to have pending error conditions. It is very ambiguous but may be considered that a remote server's error conditions are not the socket's error conditions. But it is just a wild guess – Sergey Kolesnik Jun 06 '21 at 13:59

0 Answers0