当前位置:Gxlcms > PHP教程 > cli模式的stream_socket_accept函数有关问题

cli模式的stream_socket_accept函数有关问题

时间:2021-07-01 10:21:17 帮助过:20人阅读

cli模式的stream_socket_accept函数问题
本帖最后由 jdgdf566 于 2013-08-30 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: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
apache下没有此问题。 socket

分享到:


------解决方案--------------------
不晓得,你的错误信息是超时,就是连接不上

查一下$errno

人气教程排行