When you use keep-alive, the connection will not be closed after the first request. When the client wants to send a new request, it will just reuse the same connection, so your read callback will be called again. You shouldn't even need to call uv_read_start() again.
How can I tell data arrives on a HTTP keep-alive connection?
-
12-07-2023 - |
Question
I am implementing a simple web server using libuv. Currently I am stuck with the keep-alive connection.
Based on my understanding of keep-alive, I just do not call uv_close()
on the established connection(a TCP socket) after a request is processed, and reuse it latter.
I am wondering how can I tell a new request arrives on that connection?
That is, when should I call uv_read_start()
on that alive connection?
Solution
OTHER TIPS
Immediately you have finished writing the prior response.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow