[Twisted-Python] peer 2 peer, udp, stdio -> very confused

hi all, first: I have been reading the topics on this list regarding apps that need to be client/server at the same time, use udp, need to be able to react to user input while the reactor is running with much interest, but I'm very confused now as to how I should proceed with my own problem. In short: I'm trying to create a peer 2 peer application that has a text-based gui (commandline), driven by user input and communicates with other peers over udp (and occasionally over tcp, to transfer files). I'm just really confused over some basic concepts. Am I correct that I can just create a simple class extending protocol.DatagramProtocol to facilitate the raw udp sending / receiving? Then use that in a Factory class (MyClientFactory) to 'layer' the p2p protocol functionality on? Where do I put my stdio implementation then? And am I right that the only thing needed for udp to work is to do a reactor.listenUDP(portnum, MyClientFactory()) or do I need to use two factory classes, one for the client 'bit' and one for the server? I realise that's a lot of questions, but the sheer size of twisted has overwhelmed me a bit and I'd appreciate any help you can give.

On Mon, 4 Dec 2006 10:26:10 +0100, varname <varname@gmail.com> wrote:
That is how UDP works with Twisted, yes.
Then use that in a Factory class (MyClientFactory) to 'layer' the p2p protocol functionality on?
Protocol factories aren't involved in UDP, since their purpose is to expose the concept of a connection with a limited lifetime, a concept lacking in UDP.
Where do I put my stdio implementation then?
Standard IO is treated as a connection-oriented transport, so you interact with it in much the same way as you would interact with a TCP connection. The primary difference is that instead of creating a factory and passing it to connectTCP, you just create your protocol and instantiate StandardIO with it.
Since there is only listenUDP, there's no place for a 2nd DatagramProtocol to go. You can manage both sending and receiving datagrams with a single instance. Jean-Paul

On Mon, 4 Dec 2006 10:26:10 +0100, varname <varname@gmail.com> wrote:
That is how UDP works with Twisted, yes.
Then use that in a Factory class (MyClientFactory) to 'layer' the p2p protocol functionality on?
Protocol factories aren't involved in UDP, since their purpose is to expose the concept of a connection with a limited lifetime, a concept lacking in UDP.
Where do I put my stdio implementation then?
Standard IO is treated as a connection-oriented transport, so you interact with it in much the same way as you would interact with a TCP connection. The primary difference is that instead of creating a factory and passing it to connectTCP, you just create your protocol and instantiate StandardIO with it.
Since there is only listenUDP, there's no place for a 2nd DatagramProtocol to go. You can manage both sending and receiving datagrams with a single instance. Jean-Paul
participants (2)
-
Jean-Paul Calderone
-
varname