eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.61k stars 751 forks source link

Question about Timeouts. #163

Open SethHamilton opened 6 years ago

SethHamilton commented 6 years ago

https://github.com/eidheim/Simple-Web-Server/blob/b9d4be229f41e3eda72394451d479f5245d2a600/server_http.hpp#L233

Does this associate the timer with connection so it gets cancelled automatically when the connection is closed?

eidheim commented 6 years ago

The timers are not associated with sockets, but all the async operation handlers start with calling the Connection::cancel_timeout()-function. See for instance https://github.com/eidheim/Simple-Web-Server/blob/b9d4be229f41e3eda72394451d479f5245d2a600/server_http.hpp#L423. In the event of a connection close, one of these handlers will be called with an error code ec set.

SethHamilton commented 6 years ago

Cool, I see it. Thank you.