Reputation: 35
I have multiple server endpoints listening on different ports, using same protocol and factory
How do I know which one has made connection first?
endpoint1 = TCP4ServerEndpoint(reactor, 8007)
endpoint.listen(QOTDFactory())
endpoint2 = TCP4ServerEndpoint(reactor, 8008)
endpoint2.listen(QOTDFactory())
and so on....
Upvotes: 3
Views: 719
Reputation: 31860
There's no way for you to tell the difference, since the objects you've constructed are exactly the same. If you wanted to tell the difference, consider something like:
endpoint1 = TCP4ServerEndpoint(reactor, 8007)
endpoint.listen(QOTDFactory("tweedledee"))
endpoint2 = TCP4ServerEndpoint(reactor, 8008)
endpoint2.listen(QOTDFactory("tweedledum"))
Then, in QOTDFactory.buildProtocol
, you can easily print out whether your factory is tweedledee
or tweedledum
.
Upvotes: 2