tcp_read()


读取指定TCP会话(session)的接收数据

Description

int tcp_read(int $tcp_id, string &$rbuf [, int $rlen = MAX_STRING_LEN])

Parameters

Return Value

成功时读取数据大小(字节数),失败时 0

Example

<?php
include "/lib/sn_tcp_ac.php";
$port = 1470;
tcp_server(0, $port);         // listenning the port for a TCP connection (TCP ID: 0)
$rbuf = "";
while(1)
{
  $rlen = tcp_read(0, $rbuf); // Reading TCP receiving buffer
  if($rlen > 0)
    echo "$rbuf\r\n"; 
}
?>

See also