cli模式的stream_socket_accept函数问题
本帖最后由 jdgdf566 于 2013-08-30 17:41:37 编辑
/* Open a server socket to port 1234 on localhost */<br />
$server = stream_socket_server('tcp://127.0.0.1:12345');<br />
<br />
$socket = stream_socket_accept($server);<br />
<br />
/* Grab a packet (1500 is a typical MTU size) of OOB data */<br />
echo "Received Out-Of-Band: '" . stream_socket_recvfrom($socket, 1500, STREAM_OOB) . "'\n";<br />
<br />
/* Take a peek at the normal in-band data, but don't comsume it. */<br />
echo "Data: '" . stream_socket_recvfrom($socket, 1500, STREAM_PEEK) . "'\n";<br />
<br />
/* Get the exact same packet again, but remove it from the buffer this time. */<br />
echo "Data: '" . stream_socket_recvfrom($socket, 1500) . "'\n";<br />
<br />
/* Close it up */<br />
fclose($socket);<br />
fclose($server);
로그인 후 복사
PHP Warning: stream_socket_accept(): accept failed: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
apache下没有此问题。