The intention of this post is to figure out how to implement a Keep-Alive timeout on a Boost ASIO based HTTP server.
There are 2 parts to this -
- When the client has closed the connection
- When the client connection is inactive
I believe, 1) above can be detected by setting the TCP_KEEPIDLE, TCP_KEEPCNT and TCP_KEEPINTVL options on the native socket handle.
What is the best way to detect 2) above?
I have tried setting the SO_RCVTIMEO and SO_SNDTIMEO on the native socket, but the server doesn't seem to close the connection at the end of the configured timeout interval.
Any pointers are much appreciated.
Thanks!