Example #1
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
ob_implicit_flush();
$sk = new Sock('120.76.84.162', 8080);
//$sk = new Sock( '127.0.0.1' , 8080 );
$sk->run();
class Sock
{
    public $sockets;
    public $users;
    public $master;
    public $client;
    private $sda = [];
    //已接收的数据
    private $slen = [];
    //数据总长度
    private $sjen = [];
    //接收数据的长度
    private $ar = [];
    //加密key
    private $n = [];
    public function __construct($address, $port)
    {
        $this->master = $this->WebSocket($address, $port);
        $this->sockets = [$this->master];
    }
    function run()
    {
        while (true) {
            $changes = $this->sockets;