On Fri, Feb 8, 2019 at 8:15 AM Steve Richter <stephenrichter@xxxxxxxxx>
wrote:
On the client side that means using the WebSocket class? Does the PHP Zend
server support websockets?
On the browser side you can use:
a. Page refresh in a loop (primitive and resource intensive).
b. AJAX polling, perhaps every few seconds (client and server resource
intensive, delayed response).
c. AJAX long polling, where client waits, server alternates between
sleeping and polling (server resource intensive, delayed response).
d, Web sockets, where either side, both client and server can initiate
communications a any time (efficient, traditional socket I/O).
I don't think Zend Server supports web sockets, but I came across a
conference presentation that featured a technique where a separate PHP
process was run in tandem with a PHP web server, where the separate process
used a PHP compatible sockets library. The presenter said the workflow was
tricky, and not for the faint of heart.
The vast majority PHP chat services use option (b) above. I don't think
long polling is used much in PHP because each connection ties up a server
process. Shops typically run only a dozen or so PHP processes, and they
don't want to tie them up with sleep() calls.
As an Amazon Associate we earn from qualifying purchases.