send($server->getUri()); $socket = yield $server->accept(); if (!$socket instanceof ChannelledSocket) { throw new \RuntimeException('Socket is not instance of ChanneledSocket'); } $ping = yield $socket->receive(); if ($ping !== 'ping') { throw new \RuntimeException("Received $ping instead of ping!"); } yield $socket->send('pong'); yield $socket->disconnect(); $server->close(); return $server->accept(); };