The stream_socket_accept function in cli mode is edited by jdgdf566 at 17:41:37.
Socket
/* 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.
Reply to discussion (solution)
Does the firewall allow php?
Does the firewall allow php? Firewall not installed
I don't know. your error message is timeout, or the connection fails.
Check $ errno
I don't know. your error message is timeout, or the connection fails.
Check that $ errno is indeed timeout. When the second parameter of stream_socket_accept ($ server) is 0, it is not an infinite time. This function should be used in the loop structure. The preliminary conclusion is as follows.