crow
crow copied to clipboard
shutdown before close
Tick value is 5 second by default, timer will expire if interval betweent two request is larger than 5 seconds.
Server will close the socket if timer is expired, but Client still send HTTP request to the socket.
the length of data usingasync_read_some from the socket is 0, HTTP request from client skipped, and callback will not invoke!
It's ok if shutdown before close, so Client will receive FIN and close the socket, then start 3-way handshake.
Have tested using tcpdump and Wireshark.
boost/asio/basic_socket.hpp also recommend to shutdown before close, reference below:
@note For portable behaviour with respect to graceful closure of a connected socket, call shutdown() before closing the socket.