def _connected(self, sock):
        """When the socket is writtable, the socket is ready to be used."""
        logger.debug('socket connected, building protocol')
        self.protocol = self.factory.build(self.loop)
        self.connection = Connection(self.loop, self.sock, self.addr,
            self.protocol, self) 
        self.connector = None
        self.connect_deferred.callback(self.protocol)
When the socket is writtable, the socket is ready to be used.