I'm implementing a basic HTTP Server in C++, using boost::asio.
As I process each request, I write out the data in chunks, asychronously. If at any point I knew the client was no longer connected, I'd like to abort the processing, e.g. there's no point continuing to build results up to send out if the client is no longer there.
I think this has already been asked here a few times, e.g.:
But I reading them I'm still not sure what a good approach here is.
- Can I try to read from the client socket? (Even knowing that the HTTP client at the other end isn't going to be sending any data)
- Because I'm writing asynchronously (using boost::asio::async_write), I don't seem to receive feedback if the client is no longer there