Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

Immediately you have finished writing the prior response.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top