简体   繁体   中英

php socket not the whole data

I'm trying to make a site where all clients will be connected with the server and communicate with each other. What I need to do is to create sockets.

I know that through this technique, whenever a client does some action, then the other clients can immediately see it because the server will "push" the data to them (something like that. I am new to sockets anyway).

However, I don't want EVERY client to be able to see ANY data about what the other clients do, but ONLY what they have the privilege to see. (privileges are calculated through some values in a database).

Is socket programming able to do that? If not, then I will figure out another way to make my site, maybe long-polling. (If yes, an example would be appreciated a lot)

Yes, socket programming in PHP is able to do that. When you write your PHP code, you can choose what to write to each socket.

There is no way to send to "all sockets at once", you will need to loop through the sockets and send data to each socket. In this loop, you are of course able to check "privileges" to make sure that you don't send anything the client should not see.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM