读取指定保存长度的TCP会话(session)的数据
int tcp_readn(int $tcp_id, string &$rbuf, int $rlen)
成功时读取数据大小(字节 数),失败时 0
<?php
include "/lib/sn_tcp_ac.php";
$port = 1470;
tcp_server(0, $port); // listenning as a server
$rbuf = "";
while(1)
{
$rlen = tcp_readn(0, $rbuf, 100); // If there are data equal to or more than 100, it copies 100 bytes of data to the $rbuf and returns 100
if($rlen > 0)
echo "$rbuf\r\n";
}
?>