'Return a Deferred and store it for future use.  (Implementation of
L{IStreamServerEndpoint}).
@param factory: the factory to listen with
@return: a L{Deferred} stored in L{FakeServer.result}'

def listen(self, factory):

    self.listenAttempts += 1
    self.factory = factory
    self.result = Deferred(canceller=(lambda d: d.errback(self.cancelException)))
    if (self.failImmediately is not None):
        self.result.errback(self.failImmediately)
    return self.result
