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