【发布时间】:2015-08-06 22:34:22
【问题描述】:
我有一个用 PHP 编写的 UDP 守护程序,用于从远程 UDP 设备接收数据。
$sock = socket_create(AF_INET, SOCK_DGRAM, 0);
socket_bind($sock, 0, $port) or die('Could not bind to address');
while (true) {
$r = socket_recvfrom($sock, $buf, 65535, 0, $remote_ip, $remote_port);
echo "$remote_ip : $remote_port -- " . $buf ."\n";
echo strlen($buf) . "\n";
// DO DATABASE FUNCTIONS
}
有没有办法在每 x 次迭代后刷新缓冲区,因为它似乎在某个点被填满并且数据库函数似乎不再运行,直到我终止并重新启动应用程序?
数据并不重要(这就是我使用 UDP 的原因)
【问题讨论】: