stream_socket_accept function problem for CLI mode

Source: Internet
Author: User
This post was last edited by jdgdf566 on 2013-08-30 17:41:37

Socket

/* Open a server socket to port 1234 on localhost */$server = stream_socket_server (' tcp://127.0.0.1:12345 '); $socket = Stre Am_socket_accept ($server);    /* Grab a packet (is a typical MTU size) of OOB data */    echo "Received out-of-band: '". Stream_socket_recvfrom ($socket, Stream_oob). "' \ n";    /* Take a peek at the normal in-band data, but don ' t comsume it. *    /echo "Data: '". Stream_socket_recvfrom ($socket, Stream_peek). "' \ n";    /* Get The exact same packet again, but remove it from the buffer this time. *    /echo "Data: '". Stream_socket_recvfrom ($socket, 1500). "\ n";/* Close it Up */fclose ($socket); fclose ($server);

PHP warning:stream_socket_accept (): Accept failed: The connection attempt failed because the connecting party did not respond correctly after a period of time or the connected host was unresponsive.
There is no such problem under Apache.


Reply to discussion (solution)

Has the firewall released PHP yet?

Has the firewall released PHP yet? No firewall installed.

Do not know, your error message is timed out, is not connected

Check the $errno.

Do not know, your error message is timed out, is not connected

Check out that $errno really is a timeout. Stream_socket_accept ($server) is not an infinite time when the second parameter is 0. This function should be used in the loop structure. The preliminary conclusion is this.

  • 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.