[Twisted-Python] udp

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

You shouldn't need the makeconnect stuff. Try this: from twisted.internet.protocol import DatagramProtocol from twisted.internet import reactor class testcomms(DatagramProtocol): def datagramReceived(self, data, (host, port)): print 'Received ', data, 'from ', host self.transport.write('this is a test', (host, port)) reactor.listenUDP(8000, testcomms()) reactor.run() -Black On Jun 6, 2007, at 3:42 PM, Bruce Coram wrote:
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
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (2)
-
Black
-
Bruce Coram