What is Long-Polling, WebSockets, SSE and Comet? How to implement them in PHP?
Hi everyone! I'm a beginner PHP developer and recently faced a task: I need to make a chat on a website so that messages arrive without reloading the page. I know about AJAX, but there you need to constantly send requests, which is inefficient. I started googling and came across the terms: Long-Polling, WebSockets, Server-Sent Events (SSE) and Comet. Honestly, I'm confused.
So far I understand it like this: Long-Polling is when the client sends a request, and the server keeps it open until a new message appears. But how to implement this in PHP? PHP is single-threaded, it can't hang for a long time, otherwise memory will run out. WebSockets is a persistent connection, but I've heard that PHP is not very suitable for this, you need to use Node.js or Go. And SSE is something like a data stream from the server to the client, but it seems like it works
No answers yet.
Log in to leave an answer
Blogs