private function createConnection($endpoint)
    {
        // port
        $port = $this->getOption('ssl') == true ? 443 : 80;

        if (!($connection = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
            $errorcode = socket_last_error();
            $errormsg = socket_strerror($errorcode);
            throw new Exception\EndpointServerException('Analytics Socket failure! Error: ' . $errormsg);
        }

        if (!socket_connect($connection, $endpoint['host'], $port)) {
            $errorcode = socket_last_error();
            $errormsg = socket_strerror($errorcode);
            throw new Exception\EndpointServerException('Analytics Host not reachable! Error: ' . $errormsg);
        }

        socket_set_option($connection, SOL_SOCKET, SO_RCVTIMEO, array('sec' => self::READ_TIMEOUT, 'usec' => 0));

        if ($this->getOption('async')) {
            socket_set_nonblock($connection);
        }

        $this->connection = $connection;
    }