Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from twisted.internet import reactor
- from twisted.internet.protocol import Protocol, Factory, DatagramProtocol
- class TCPServer(Protocol):
- def dataReceived(self,data):
- print('TCP client said: {!r}'.format(data))
- class TCPServerFactory(Factory):
- def buildProtocol(self, addr):
- return TCPServer()
- class UDPServer(DatagramProtocol):
- def datagramReceived(self, data, addr):
- print('UDP client said: {!r}'.format(data))
- reactor.listenTCP(9997, TCPServerFactory())
- reactor.listenUDP(9998, UDPServer())
- reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement