[100] can PHP create a Socket persistent connection with resident memory? Hi, everyone. ask for help. I want to meet the following requirements:
A persistent Socket connection is created during system logon. during The valid logon time, the Socket is connected to the resident memory, and all pages in the system use the Socket connection to communicate with the remote server;
The connection is closed only when the logon expires or the user logs out of the system.
I'm not mistaken ...... PHP variables are released after the script execution is completed. Is there any way to meet the above requirements?
P.SI am using pfsockopen to create a Socket connection. The php official website describes this function:
This function behaves exactly as fsockopen () with the difference that the connection is not closed after the script finishes. It is the persistent version of fsockopen ()
How can I understand the red part? Can this function meet my current needs?
Thanks!
Reply to discussion (solution)
So far, php has not provided the websock service function.
That is to say, you can only write the server code in cli mode by yourself.
So far, php has not provided the websock service function.
That is to say, you can only write the server code in cli mode by yourself.
Amount ...... The newbie said that this section [the server code for writing cli by myself] is not clear. please explain it in detail when you are free, Thanks!
Cli is a common command line method.
If you don't even understand this, you can't write it out.
Of course, the thread server code can be found on the Internet, but you cannot modify the code if your water is too low.
Cli is a common command line method.
If you don't even understand this, you can't write it out.
Of course, the thread server code can be found on the Internet, but you cannot modify the code if your water is too low.
--Well, maybe I did not describe it clearly. CLI knows it ......
Can I recommend some open-source projects? Refer to Thanks ~~
Cli is a common command line method.
If you don't even understand this, you can't write it out.
Of course, the thread server code can be found on the Internet, but you cannot modify the code if your water is too low.
--Well, maybe I did not describe it clearly. CLI knows it ......
Can I recommend some open-source projects? Refer to Thanks ~~
The main cli can be implemented
For open-source projects, refer to workerman, which specializes in PHP server communication.