if(socket_recv ( $sock , $buf , 2045, MSG_WAITALL ) === FALSE)
{
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
die("Could not receive data: [$errorcode] $errormsg <br>");
}
echo $buf;
Run Code Online (Sandbox Code Playgroud)
从上面的函数它没有显示完整的消息,所以我试图得到这样的变量$ buf的最大长度
socket_recv($ sock,$ buf,strlen($ buf),MSG_WAITALL)
但不行.请帮助我
thx和问候,
小智 4
您应该收到带有循环的响应
$received;
while(socket_recv($sock, $buf, 1024, 0) >= 1)
{
$received .= $buf;
}
Run Code Online (Sandbox Code Playgroud)