javascript - PHP freezes on sleep() -


I was voting for a chat script for a long time. I have designed it to work like this:

  1. Customer sends a request for server (php)
  2. The server is requested, and a loop (For 1 minute)
  3. On every iteration in the loop, the server checks the 'new' messages from the database
  4. If there is a new message, the new message The server with the list dies. (I used the die string function
  5. That response is received by the customer, and is processed.
  6. If there is no new message for 1 minute , The other dead () function looks like a

code with a 'message' status:

  & lt ;? php while ($ time) & Lt; 60) {If (new message) (die (new message)} So (1); $ Time ++;} die (no new message);  

During 60 seconds (when this is any new message I'm unable to open a new page, nor are other users able to access any page (using xampp). How do I fix this problem? I know that this approach can not be so great, but I would like to know this problem, and how to solve it, rather it is suggesting how to do it in any other way (Web sockets, etc.)


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -