How can I make the server listen on TCP and UDP?

I use python twisted and I have two separate servers running: one that receives TCP, one that receives UDP, and each of them uses

reactor.listenTCP(PORT, factory)
reactor.run()

and

reactor.listenUDP(PORT, BaseThreadedUDPServer())
reactor.run()

They work, but now I want to combine them on one server, which receives both TCP and UDP, but they both use a variable reactor. Isn't that a twist reactor, not mine. If it were my own, I could just change the name for each.

Thank!

+3
source share
2 answers

This is just a paraphrase of MarkR's answer, which is correct, but I thought it would be a little clearer to explain how this works:

, , :

reactor.listenTCP(PORT, factory)
reactor.listenUDP(PORT, BaseThreadedUDPServer())
reactor.run()

reactor.run() " , , ". . , , , .

+5

listenTCP listenUDP , , .run()

, .

+4

Source: https://habr.com/ru/post/1778907/


All Articles