[Twisted-Python] New UDP API

Itamar Shtull-Trauring twisted at itamarst.org
Tue Oct 29 23:23:09 MST 2002


On Wed, 30 Oct 2002 00:59:11 -0500
Itamar Shtull-Trauring <twisted at itamarst.org> wrote:

> I just checked in a refactored UDP API into CVS. Please take a look
> and comment.

And I guess some explanations are in order. I disabled twisted.names
test for the checkin, as it tests were failing. Commenting out tests
cause they break is a bad thing - DO NOT DO THIS AT HOME CHILDREN. I
only did it because names was inherently broken, as conformed by the
maintainer. And looks like I volunteered to do some fixing :/

Anyway, the new API:

Unconnected UDP ports
=====================
   port = reactor.listenUDP(port, protocol)

protocol is instance of DatagramProtocol, which unlike TCP protocols is
expected to be persistent. It will get start/stopProtocol called at the
appropriate time.

protocols' datagramReceived(data, (host, port)) method will be called
when they receive datagram, and the can self.transport.write(data,
(host, port)).


Connected UDP ports
===================
   port = reactor.connectUDP(remotehost, remoteport, protocol)

protocol is instance of ConnectedDatagramProtocol, which unlike TCP
protocols is expected to be persistent. It will get start/stopProtocol
called at the appropriate time.

protocols' datagramReceived(data) method will be called when they
receive datagram, and the can self.transport.write(data).

-- 
Itamar Shtull-Trauring    http://itamarst.org/
Available for Python, Twisted, Zope and Java consulting
***> http://VoteNoWar.org -- vote/donate/volunteer <***




More information about the Twisted-Python mailing list