'Implement L{IStreamServerEndpoint.listen} to start listening on, and
then close, C{self._fileno}.'

def listen(self, factory):

    if self._used:
        return defer.fail(error.AlreadyListened())
    self._used = True
    try:
        self._setNonBlocking(self.fileno)
        port = self.reactor.adoptStreamPort(self.fileno, self.addressFamily, factory)
        self._close(self.fileno)
    except:
        return defer.fail()
    return defer.succeed(port)
