Question about the stream_socket_accept function in cli mode-php Tutorial

Source: Internet
Author: User
Stream_socket_accept function problems in cli mode This post was last edited by jdgdf566 at 2013-08-3017: 41: 37 * & nbsp; Open & nbsp; a & nbsp; server & nbsp; socket & nbsp; to & nbsp; port & nbsp; 1234 & nbsp; on & nbsp; stream_socket_accept function in localhost & cli mode

This post was last edited by jdgdf566 at 17:41:37

/* Open a server socket to port 1234 on localhost */
$server = stream_socket_server('tcp://127.0.0.1:12345');

$socket = stream_socket_accept($server);

/* Grab a packet (1500 is a typical MTU size) of OOB data */
echo "Received Out-Of-Band: '" . stream_socket_recvfrom($socket, 1500, STREAM_OOB) . "'\n";

/* Take a peek at the normal in-band data, but don't comsume it. */
echo "Data: '" . stream_socket_recvfrom($socket, 1500, 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.
This problem does not occur in apache.

Socket

Share:


------ Solution --------------------
I don't know. your error message is timeout, or the connection fails.

Check $ errno

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.