How to interrupt PHP socket

Source: Internet
Author: User
I have PHP built a socket loop listening port
while (true) {
Recv .....
}
Now trouble, this page F5 re-run no effect, the port has been monitored
I changed the code effect does not come out
We have to restart the machine.
Wow, it happens every time, so it's too much trouble to debug.


Reply to discussion (solution)

So you're not dealing with the listening stuff?

So you're not dealing with the listening stuff? What do you mean, deal with it?
But I changed the contents of the while and the client returned the original thing.
Close the page (PHP), the client still returns like that
The server must be restarted and then re-opened
Just like the cache, but I looked at the shell box, and the port really was listening.
How does the service end soft restart, thank you

Since you are dealing with the data sent by the client, you can contract a termination signal
When you receive the termination signal, you jump out of the loop and Socket_close.

It's not clear.
Theoretically captures a condition within a while, and when satisfied is on break then close is available
As for the cache problem This is strange, how can the socket receive the old information?
Web page to do this kind of content generally to set the immediate expiration (do not cache) and automatic refresh

You can debug it with the CLI mode.

Well, let the client send the termination message, a little bit of security issues, but now don't think about it, you can handle
To#4, I said that the cache is a metaphor for the result of the phenomenon, the socket is locked, anti-repetitive start, the cause is the socket after the boot is not closed, I do not need to listen or stop, can not debug the server update content; For example, someone comes up, sends a Hello, I changed hello to Hallo, no reboot received Hallo, always hello

To#5,cli never heard of Oh, study ~
Thank you, three-bit, knot-post.

  • Related Article

    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.