laponac84 Posted November 25, 2014 Share Posted November 25, 2014 Halloi start learning Socket and php programming for now successfully manage to make the communication between the client and the server, by sending an automatic message from the system. I am interested in the following: 1. Does the server can send messages to specific client ? or server send to all client, and then client make filter of message (this is for me, this is not)?2. How i can menage number of connection ?3. How i can menage to make live client and server?I make while(true){ // code } part of code for make server live, but this way is not too functional, because the server does not see what was happening, I can see the response message to the client onlyPS: Is there any bether solution ? Quote Link to comment Share on other sites More sharing options...
requinix Posted November 25, 2014 Share Posted November 25, 2014 1. It can do either. Or both. IRC servers do both: send a chat message to all clients, and send a user-specific message to a specific client. 2. You delve into multi-threading. Briefly, when the server accept()s it creates a new thread to handle the client, and the server immediately waits for the next connection. Meanwhile the new thread does whatever it is supposed to. The main thread and the new thread can communicate with each other too. To manage the number of connections, the server stops accepting connections when it has too many child threads/connections active. 3. I don't know what you mean by "make live". I make while(true){ // code } part of code for make server live, but this way is not too functional, because the server does not see what was happening, I can see the response message to the client onlyDon't know what you're trying to say there either. PS: Is there any bether solution ?What you have there is the standard pattern for a single-threaded server/client architecture. A "better solution" would be multi-threading. Quote Link to comment Share on other sites More sharing options...
laponac84 Posted November 26, 2014 Author Share Posted November 26, 2014 maybe'm a little confused, but I need the following:First:1. the current version of football manager that I made with PHP + MySQL, jQuery ... not contained live online game with two opponents. In this (old version) it was possible to only see the final result (not to be part of live game).2. i know how to make live game with refreshing page, or div on some "N" second. to read data form Mysql, but this is not ok solution.Second: what is actually needed?For example: i have two player online live in the game, i need 1. one server to create events in the game (attack from the left with a strike from the middle of ... , red card ...) and wait (read) to the client signals (two direct players), or more directly, the changes of formation and the players themselves2. Two (or more) clients for Reading messages from the server (the event that the server will create, change tactics and composition of the teams that will make the other opponent) and send a message to the server (substitutions and tactics)on Google when you type "PHP client server", most links have a socket, so I read about himwith PHP + MySQL, jQuery i know how to make this, but with lots of refreshing of content, and if i have 10.000 users, i think that this is not smart solution What is the best solution for me?PS1: i make all code in local server (easy php) I also have a good web hosting, if necessary. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.