Today research websocket time, found online many websocket+php demo is to enter the command line Php-q xxx.php to start the server, I am not very familiar with PHP, I would like to ask the following this scenario can be achieved?
The browser Ajax request creates the Socket--> server to receive and establish the socket, which returns the socket address and port,
The browser receives the socket address and port, starts new WebSocket, and establishes a socket link with the server.
In addition: each browser and the same server to establish a socket connection, the service side is not to open a new process??
Reply content:
Today research websocket time, found online many websocket+php demo is to enter the command line Php-q xxx.php to start the server, I am not very familiar with PHP, I would like to ask the following this scenario can be achieved?
The browser Ajax request creates the Socket--> server to receive and establish the socket, which returns the socket address and port,
The browser receives the socket address and port, starts new WebSocket, and establishes a socket link with the server.
In addition: each browser and the same server to establish a socket connection, the service side is not to open a new process??
Run the service side using the command line because it is more robust and does not attempt to establish a service side as a Web service such as PHP-FPM or Apache.
PHP Writing service side, you can consider using this, http://www.swoole.com/.
Generally stable servers are run in the form of Deamon.
Upstairs said the Swoole is the C extension implementation of the PHP socket server, similar to the Workerman,workerman is based on PHP pcntl implementation, can be said to be native PHP implementation, The common point is to be sure to run the server in the form of Deamon, leaving the HTTP layer of Apache or nginx, go directly to the socket (as I understand, is the transport layer of things).
Ajax can be linked to the server, you may, I mean, might encounter Ajax cross-domain issues.