[Twisted-Python] UDP and factories
mesozoic at polynode.com
Fri Aug 8 20:21:23 EDT 2003
On Fri, Aug 08, 2003 at 05:18:05PM -0600, John Janecek wrote:
> I am attempting to use DatagramProtocol with a factory
> are u supposed to use DatagramProtocol with a factory ??
> am i out to lunch ?
Yes, you are -- but don't worry, it was leftover ham sandwiches ;]
No, you do not need to use a factory for a DatagramProtocol. Thus:
> from twisted.internet.protocol import DatagramProtocol
> from twisted.internet import reactor
> class Echo(DatagramProtocol):
> def datagramReceived(self, data, (host, port)):
> print "received %r from %s:%d" % (data, host, port)
> self.transport.write(data, (host, 7000))
Look at <http://twistedmatrix.com/documents/howto/udp> for more information.
"Never let your sense of morals prevent you from doing what is right."
-- Salvor Hardin, Isaac Asimov's _Foundation_
More information about the Twisted-Python