illustrate
1. Long connection means that after a SOCKET connection is established, the connection is maintained regardless of whether it is used, but the security is poor.
Every time we access a PHP script, we will get the return result only after all PHP scripts have been executed. If you want the script to run continuously, you must use PHP long connection to achieve the purpose of operation.
Application scenarios
2. Long connections can save more TCP establishment and closing operations, reduce resource waste, and save time.
For clients that request resources more frequently, long connections are more suitable.
Example
<?php header("Content-Type: text/plain"); set_time_limit(0); while(true) { //Continuously executed script flush(); ob_flush(); sleep(5); } ?>
The above is an introduction to PHP long connection, I hope it will be helpful to everyone.