0

Suppose we have a normal website like a forum for example, and somewhere in the website the users can talk to each other through a chat box down at the corner.

If we want to use web sockets (not AJAX polling) for the live chat, PHP should run in an infinite loop through the command line to keep the web sockets server alive. Is it possible to handle the HTTP requests and keep the loop running (without using anything outside of PHP like Nodejs,etc..) ?

  • Have you read https://stackoverflow.com/questions/28516962/how-websocket-server-handles-multiple-incoming-connection-requests ? – Martin Nov 07 '19 at 12:47
  • I'm sure you can do it using two PHP instances, one for the websocket and one for the HTTP but this may be resource heavy on the server (PHP instances = visitors x 2) ? – Martin Nov 07 '19 at 12:48

0 Answers0