ws_setup()


websocket服务器设定及等待连接

Description

void ws_setup(int $tcp_id, string $path, string $proto [, $port = 0])

Parameters

Return Value

none

Example

<?php
include "/lib/sn_tcp_ws.php";
ws_setup(0, "my_path", "my_proto");   // Configuring a websocket and waiting for a connection
while(1)
{
  if(ws_state(0) == TCP_CONNECTED)
  {
    ws_write(0, "hello, world!\r\n"); // Sending a message to the websocket
    sleep(1);
  }
}
?>

See also