无论我们是否成功监听,都不会调用回调。这里发生了什么?
def server_started(self, data, port):
log.msg("Server listening on port %s." % (port))
def server_failed(self, data, port):
log.err("Failed to listen on port %s." % (port), data)
reactor.stop()
log.startLogging(sys.stdout)
port = 6000
endpoint = TCP4ServerEndpoint(reactor, port)
d = endpoint.listen(MyFactory())
d.addCallback(server_started, port)
d.addErrback(server_failed, port)
reactor.run()