Can the phpsocket server be enabled on the webpage? Instead of enabling it in CLI mode

Source: Internet
Author: User
Can the phpsocket server be enabled on the webpage? Instead of enabling the php socket-based chat program in CLI mode, you have encountered the following problems:
To enable the ws port, you can only enable the port in the php server. php mode under CMD. the CMD command line window cannot be closed. Once closed, the socket connection is closed.
Can I enable the ws server in this way instead of on the webpage? How?


Reply to discussion (solution)

You can enable it on the website, but pay attention to the following issues:
1. because the port cannot be opened repeatedly, you must ensure that server. php will only run once.
2. the php timeout setting in web mode is valid. of course, you need to set it to never time out.
3. there is a timeout limit on the web server, although it takes a long time. Applications that have no data output for a long time will be suspended or interrupted
4. if server. php occasionally outputs standard output, the problem 3 can be solved. But it will cause the next problem.
5. When php writes data to the standard output, it checks whether the connection to the request source is smooth. If the request source is disabled, the program will be terminated.
Of course, there are also methods to prevent this default behavior.

In fact, the existence of the command window is not a bad thing. at least it can indicate that the ws server is working.
In addition, when the ws server is running, you should print important log information in the window to monitor the running status in real time.

You can enable it on the website, but pay attention to the following issues:
1. because the port cannot be opened repeatedly, you must ensure that server. php will only run once.
2. the php timeout setting in web mode is valid. of course, you need to set it to never time out.
3. there is a timeout limit on the web server, although it takes a long time. Applications that have no data output for a long time will be suspended or interrupted
4. if server. php occasionally outputs standard output, the problem 3 can be solved. But it will cause the next problem.
5. When php writes data to the standard output, it checks whether the connection to the request source is smooth. If the request source is disabled, the program will be terminated.
Of course, there are also methods to prevent this default behavior.

In fact, the existence of the command window is not a bad thing. at least it can indicate that the ws server is working.
In addition, when the ws server is running, you should print important log information in the window to monitor the running status in real time.



Thank you very much for your analysis and answers!
In win, the CMD window is always running and cannot be closed. Once closed, the socket service will be stopped, and the window will always have the urge to close on the desktop, or it will be closed accidentally. That's why I came up with such a trick!
The pipeline is created in the command line of php server.php. it is created by php.exe. do you have any disadvantages?

There are no drawbacks, especially in the debugging environment.
If it is a formal service, what is the relationship between an additional command window on the server desktop? No one will do their daily work on the server.

Okay. Thanks again.

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.