Reading the designated number of byte from the TCP session
int tcp_readn(int $tcp_id, string &$rbuf, int $rlen)
If there are data equal to or more than the $rlen in the TCP receiving buffer, it returns the $rlen, otherwise returns 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";
}
?>