From 7d91885413c58f412673342c891b2890aa7b08e3 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Sat, 28 Aug 2021 11:16:45 +0100 Subject: [PATCH] Update docs --- docs/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 638e6fac..8618aeda 100644 --- a/docs/README.md +++ b/docs/README.md @@ -100,7 +100,12 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { described for each event. Protocol-specific events usually have `ev_data` pointing to structures that hold protocol-specific information - `void *fn_data` - a user-defined pointer for the connection, which is a - placeholder for application-specific data + placeholder for application-specific data. This `fn_data` pointer is set + during the `*_listen()` or `*_connect()` call, and it is stored in the + `c->fn_data`. Listening connections copy the value of `c->fn_data` to the + newly accepted connection, so all accepted connections initially share the + same `fn_data` pointer. It is fine to update/replace that pointer for + any connection at any time by setting `c->fn_data = new_value;` ## Events