[100] can PHP create a Socket persistent connection with resident memory? -Php Tutorial

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

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.