private function handshake()
        {
            $url = $this->socketIOUrl;

            if (!empty($this->handshakeQuery)) {
                $url .= $this->handshakeQuery;
            }

            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            if (!$this->checkSslPeer) {
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            }

            if (!is_null($this->handshakeTimeout)) {
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->handshakeTimeout);
                curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->handshakeTimeout);
            }

            $res = curl_exec($ch);

            if ($res === false || $res === '') {
                throw new \Exception(curl_error($ch));
            }

            $sess = explode(':', $res);
            $this->session['sid'] = $sess[0];
            $this->session['heartbeat_timeout'] = $sess[1];
            $this->session['connection_timeout'] = $sess[2];
            $this->session['supported_transports'] = array_flip(explode(',', $sess[3]));

            if (!isset($this->session['supported_transports']['websocket'])) {
                throw new \Exception('This socket.io server do not support websocket protocol. Terminating connection...');
            }

            return true;
        }