[Twisted-Python] Mixmaster Architecture

Moshe Zadka twisted at zadka.site.co.il
Thu Nov 20 10:47:06 MST 2003


On 20 Nov 2003, "Mark Evans" <2s7l3way02 at sneakemail.com> wrote:

> Here's an architecture question for Twisted Matrix gurus.
> I need to implement a "mixmaster" scheme, as follows:
> 
>                            |--> Remote client A
>         UDP            TCP |
> Server <---> Mixmaster <---|--> Remote client B
>                            |
>                            |--> Remote client C
>                            |
>                            ... (etc.)
> 

No this is the wrong picture. Here's a right picture:

           |<--|              |--> Remote client A
        UDP|   |          TCP |
Server <---|<--|Mixmaster<----|--> Remote client B
           |   |              |
           |<--|              |--> Remote client C
           |   |              |
                             ... (etc.)

so you'll want something like

class MixmasterProtocol(protocol.Protocol) # the TCP side

    def connectionMade(self):
        self.udp = p = protocol.ConnectedDatagramProtocol()
        p.datagramReceived = self.datagramReceived
        self.server = reactor.connectUDP('127.0.0.1', PORT, p)

    def connectionLost(self):
        self.server.stopListening()

    def dataReceived(self, data):
        pass # handle data from TCP client, maybe use self.udp.transport.write

    def datagramReceived(self, data):
        pass # handle data from server, maybe use self.transport.write
 
> The most important client type uses Telnet (raw).

Make up your mind, telnet or raw? a Line-based protocol?




More information about the Twisted-Python mailing list