Creating a PHP websockets server

前端 未结 2 1560
庸人自扰
庸人自扰 2021-01-17 03:42

I am new in websockets technology. I was trying to create a websockets php server and connect to the server with a javascript client. I am using xampp 1.8.3.

I made

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 04:05

    WebSockets are not raw TCP sockets. They require a rather complex HTTP-like handshake to establish a connection, and require data transferred over them to be encoded and framed in a very particular way. The protocol is defined in RFC 6455.

    Unless you are feeling incredibly masochistic, you don't want to try to implement this yourself. Use a library like Ratchet to implement WebSockets in PHP.

提交回复
热议问题