[Twisted-Python] UDP with multiple connections

Phil Mayers p.mayers at imperial.ac.uk
Tue Oct 9 19:37:02 EDT 2007

On Tue, 2007-10-09 at 21:21 +0100, Simon Pickles wrote:
> Ok, UDP is new to me, so please be gentle....
> I've got a server authentication app which needs to accept many client 
> connections, but also dispatch messages to a master server. Am I best 
> using unconnected UDP? 

You are *best* using TCP. Very few applications are actually suited to

 * has no connection state
 * has no flow control
 * is unfriendly to networks (really the same as the previous point)
 * has no keepalives
 * has problems with MTU and fragmentation for messages > ~1400 bytes
 * is subject to trivial spoofing
 * has no message sequencing
 * is hard to run crypto over (SSL over TCP == trivial)

...and so on.

> do i then have to deal with each received 
> datagram by checking which host is has come from and acting accordingly?

Twisted's UDP support is all "unconnected". All DatagramProtocol
instances get a call to:

 def datagramReceived(self, data, addr)

...where "addr=(ip,port)" for IPv4

Similarly, you would do:

  self.transport.write(bytes, addr)

So, unconnected UDP is your *only* option, because that's how Twisted
does it.

However, so-called "connected" UDP is really just a way of saving the
destination address on the socket. There's no *actual* connection

> thanks
> Simon
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list