2012-10-13 18:21:39
0
I'm trying to set up a UDP server with Twisted folliowing this http://twistedmatrix.com/documents/current/core/howto/udp.html
However, I've hit a brickwall just starting. I tried this sample code:
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, port))
reactor.listenUDP(9999, Echo())
reactor.run()
And I get this:
def datagramReceived(self, data, (host, port)):
^
SyntaxError: invalid syntax
I'm new to Python so I'm clueless. I stripped the code down to the minimum, commenting everything but the class declaration and the method header (adding a pass) but I get the same. Are those paired parameters not supported anymore?