mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-21 20:01:46 +00:00
A read timeout set with set_read_timeout() was reported only on a frame boundary. One that elapsed inside a frame, or between the fragments of a message, failed the read and closed the connection, as what had been read could not be resumed. A small frame written in pieces often arrives in pieces on Linux, so a server polling with a short timeout lost the connection on its first message. A frame is now read by ws::impl::FrameReader, which keeps what it has read across a timeout, and WebSocket keeps the message being assembled, so read() returns Timeout wherever the timeout lands and goes on from there at the next call. close() waits for the peer's Close through the same reader. read_websocket_frame() keeps its one-shot meaning. write_websocket_frame() writes the header with the payload's first chunk in one write, and WebSocket connections set TCP_NODELAY unless CPPHTTPLIB_WEBSOCKET_TCP_NODELAY is false: on Linux, small messages each way otherwise waited on Nagle's algorithm for the peer's delayed ACK, a few in fifty around 30-40 ms late.