public function disconnect() { if ($this->socket) { stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR); } $this->socket = null; $this->connected = false; }