async def create_connection(self, protocol_factory, host, port, *,
                                resolve=False, ssl=None,
                                family=0, proto=0, flags=0):
        '''Set up a connection to (host, port) through the proxy.

        If resolve is True then host is resolved locally with
        getaddrinfo using family, proto and flags, otherwise the proxy
        is asked to resolve host.

        The function signature is similar to loop.create_connection()
        with the same result.  The attribute _address is set on the
        protocol to the address of the successful remote connection.
        Additionally raises SOCKSError if something goes wrong with
        the proxy handshake.
        '''
        loop = asyncio.get_event_loop()
        if resolve:
            remote_addresses = [NetAddress(info[4][0], info[4][1]) for info in
                                await loop.getaddrinfo(host, port, family=family, proto=proto,
                                                       type=socket.SOCK_STREAM, flags=flags)]
        else:
            remote_addresses = [NetAddress(host, port)]

        sock, remote_address = await self._connect(remote_addresses)

        def set_address():
            protocol = protocol_factory()
            protocol._proxy = self
            protocol._remote_address = remote_address
            return protocol

        return await loop.create_connection(set_address, sock=sock, ssl=ssl,
                                            server_hostname=host if ssl else None)
Set up a connection to (host, port) through the proxy.

        If resolve is True then host is resolved locally with
        getaddrinfo using family, proto and flags, otherwise the proxy
        is asked to resolve host.

        The function signature is similar to loop.create_connection()
        with the same result.  The attribute _address is set on the
        protocol to the address of the successful remote connection.
        Additionally raises SOCKSError if something goes wrong with
        the proxy handshake.