[Twisted-web] Give me your hello-world sample a and I'll do the rest (TwistedMatrix newbie)

Tzury Bar Yochay tzury.by at gmail.com
Mon Nov 3 08:30:11 EST 2008


On Mon, Nov 3, 2008 at 3:13 PM, Tzury Bar Yochay <tzury.by at gmail.com> wrote:
>>> Your question is actually a FAQ.
>>> http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#HowdoImakeinputononeconnectionresultinoutputonanother
>>>
>>> Please let us know if the answer to the FAQ could be improved or made easier
>>> to find somehow.
>>
>> thanks for the pending response. that faq is the one I needed. (As
>> always) I might should have read the FAQ before jumping into the
>> examples.
>>
>
> If I could have get that MultiEchoFactory sample using UDP it was more
> than one can wish.
>

May you add this to the FAQ:

#UDP multiEcho Sample

from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor

class MultiEcho(DatagramProtocol):
    def startProtocol(self):
        self.echoers = []

    def datagramReceived(self, data, (host, port)):
        if not (host, port) in self.echoers:
            self.echoers.append((host, port))
        print "received %r from %s:%d" % (data, host, port)
        for echoer in self.echoers:
            self.transport.write(data, echoer)

reactor.listenUDP(9999, MultiEcho())
reactor.run()

Tzury Bar Yochay



More information about the Twisted-web mailing list