[Twisted-Python] udp

Bruce Coram brucecoram at clara.co.uk
Wed Jun 6 15:42:42 EDT 2007


I know the answer to this will be soo simple but is it necessary to use 
makeConnection when using udp.  I understood that udp is a 
connectionless protocol.  I have used TCP and factories to pass data 
between a server and clients and I wanted to use udp to send 
'management' data on an ad hoc basis.  Here is the code for a very 
simple client but I'm clearly missing the point.

'from twisted.internet.protocol import DatagramProtocol

from twisted.internet import reactor


host = '127.0.0.1'

class testcomms(DatagramProtocol):

    def datagramReceived(self, data, (host, port)):
        print 'Received ', data, 'from ', host
   
    def makeconnection(self, transport):
        self.transport.write('this is a test', (host, 8000))
   

t = testcomms()
t.makeconnect(host, 8000)
reactor.listenUDP(8000, testcomms())
reactor.run()'

Thanks in anticipation

Bruce Coram







More information about the Twisted-Python mailing list