Reading data from the designated websocket session
int ws_read(int $tcp_id, string &$rbuf [, int $rlen = MAX_STRING_LEN])
the number of byte to read
<?php
include "/lib/sn_tcp_ws.php";
// configuring a websocket and waiting for a connection
ws_setup(0, "my_path", "my_proto");
$rbuf = "";
while(1)
{
if(ws_state(0) == TCP_CONNECTED)
{
ws_read(0, $rbuf); // reading data from the socket
if(strlen($rbuf) > 0)
{
hexdump($rbuf);
$rbuf = "";
}
sleep(1);
}
}
?>