Timeout on read/write using Boost.Asio
Hi everyone I'm using boost asio to implement a tcp client in my project, and it is my first time of using asio. I need timeout when read/write on the socket and I found the solution of using async io plus a timer, if timeout, cancel the async io operation. My question is: the "cancel" call acutely cancel all the pending async operation, but only one of them is timeout. For example, there is a pending async read and a pending async write operation, only read is timeout, I do not want cancel write any way. Any suggestion of the solution? Or I' m wrong? Thanks
My question is: the "cancel" call acutely cancel all the pending async operation, but only one of them is timeout. For example, there is a pending async read and a pending async write operation, only read is timeout, I do not want cancel write any way.
Yes, you're right. You'll have to issue both async read and write again. But usually "timeout" means that something goes wrong with the connection (i.e. you expected something, but it failed to happen).
participants (2)
-
boost
-
Igor R