返还webscoket session的发送缓冲器空空间
int ws_txfree(int $tcp_id)
成功时发送数据大小(字节 数),失败时0
<?php
include "/lib/sn_tcp_ws.php";
$rwbuf = "";
// configuring a websocket and waiting for a connection
ws_setup(0, "my_path", "my_proto");
while(1)
{
if(ws_state(0) == TCP_CONNECTED)
{
// Reading the data as many as the websocket TX buffer free or less
$rwlen = ws_read(0, $rwbuf, ws_txfree(0));
if($rwlen > 0)
ws_write(0, $rwbuf); // transmitting the received data
}
sleep(1);
}
?>