websocket-php socket

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.