I have a server on my arduino (WiFi) and want to save the clients that connect, so that I can send to them (to each separately) data later.
The question (and some of the answers) seem to misunderstand how HTTP works. I know how it works (at least to an extent) as I have written server scripts in Lua, as well as C++ for the Arduino.
As I mention in my page about an Arduino HTTP server when the client initiates a request it sends an HTTP header along these lines:
POST /forum/showpost.php?id=12345&page=2 HTTP/1.1
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0)
Accept-Language: en, mi
Breaking those parts down you get this:
Once the client has sent the request it awaits (on the same connection) for the server to respond. The response may look something like this:
HTTP/1.1 200 OK
Server: HTTPserver/1.0.0 (Arduino)
<h1> My heading </h1>
Notice the blank line between the HTTP header and the actual file data (the HTML data).
Under HTTP 1.1 the server can request that the connection keep open the connection by replacing:
All this means is that the client is still connected and can now request other stuff (for example an image from an
<img> tag). It does that by sending another HTTP header and then getting another response. It doesn't keep the connection open just so that the server can randomly send other stuff in the future.
Note: - the default under HTTP 1.1 is for the connections to be persistent.
... so that I can send to them (to each separately) data later.
You don't "send data later", that's not how it works. The client may request data later.