public function createClient($address)
    {
        $that = $this;
        $factory = $this->rawFactory;

        return $this->resolve($address)->then(function ($address) use ($factory, $that){
            $deferred = new Deferred();

            $socket = $factory->createFromString($address, $scheme);
            if ($socket->getType() !== SOCK_STREAM) {
                $socket->close();
                throw new Exception('Not a stream address scheme');
            }

            $socket->setBlocking(false);

            try{
                // socket is nonblocking, so connect should emit EINPROGRESS
                $socket->connect($address);

                // socket is already connected immediately?
                $deferred->resolve(new Connection($socket, $that->getSocketLoop()));
            }
            catch(Exception $exception)
            {
                if ($exception->getCode() === SOCKET_EINPROGRESS) {
                    // connection in progress => wait for the socket to become writable
                    $that->getSocketLoop()->addWriteStream($socket->getResource(), function ($resource, $loop) use ($deferred, $socket){
                        // only poll for writable event once
                        $loop->removeWriteStream($resource);

                        try {
                            // assert that socket error is 0 (no TCP RST received)
                            $socket->assertAlive();
                        }
                        catch (Exception $e) {
                            // error returned => connected failed
                            $socket->close();

                            $deferred->reject(new Exception('Error while establishing connection' , $e->getCode(), $e));
                            return;
                        }

                        // no error => connection established
                        $deferred->resolve(new Connection($socket, $loop));
                    });
                } else {
                    // re-throw any other socket error
                    $socket->close();
                    $deferred->reject($exception);
                }
            }
            return $deferred->promise();
        });
    }