Ejemplo n.º 1
0
 /**
  * onConnect is called when our socket is connected to a client.
  */
 public function onConnect($peer)
 {
     parent::onConnect($peer);
     \debug("Connected to {$peer}");
 }
Ejemplo n.º 2
0
 function client()
 {
     $sock = new Socket("tcp://127.0.0.1:8080");
     $sock->write("hello world from socket class\n");
     while (true) {
         echo ".";
         $d = $sock->read(1024, true);
         echo $d;
         usleep(500000);
     }
     $sock->disconnect();
     unset($sock);
     $s2 = stream_socket_client("tcp://127.0.0.1:8080");
     fwrite($s2, "hello world from stream_socket_client\n");
     fclose($s2);
 }
Ejemplo n.º 3
0
 /**
  * Close and/or remove the socket from the client pool.
  *
  * @param Socket $socket The socket to close
  * @return bool True if successful
  */
 public function close(Socket $socket)
 {
     $socket->disconnect();
     // Remove socket
     $uuid = $socket->uuid;
     unset($this->clients[$uuid]);
 }