Multithreading, sockets, php

0 like 0 dislike
5 views
Good.

There is a socket server in PHP, connect to him several clients, the order of communication is:

the client sends the server its id
the server responds that the id passed
the client sends the server info
the server responds that the adopted old


I can not understand, as in the case of connection of several clients to distinguish one from the other when saving data, it may happen:

cliend1id
client2id
client1data
client2data

accordingly, I is a data client 2 will receive the data client 1
by | 5 views

4 Answers

0 like 0 dislike
Pay attention to the so-called "sessions", or at least, "identifiers". Google, and even Wikipedia — both concepts.
by
0 like 0 dislike
thanks, the problem is that not found the way to get the session ID
\r
comes to mind only the creation of the array clientId=>socket connection resource
by
0 like 0 dislike
Within a socket server in php you can take a specialized solution phpDaemon or nanoserv.
Last enjoyed myself, all the users are divided into the sockets and don't get mixed up)
by
0 like 0 dislike
Why don't You pass the ID along with the data? The browsers are doing so, oddly enough.
by

Related questions

0 like 0 dislike
1 answer
asked May 22, 2019 by romaaa32
0 like 0 dislike
2 answers
asked Sep 4, 2019 by HiLevel
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
asked Aug 10, 2019 by HiLevel
0 like 0 dislike
2 answers
asked Jul 13, 2019 by HiLevel
110,608 questions
257,186 answers
0 comments
32,905 users