Module Expr Str ImportFrom alias ImportFrom alias alias ImportFrom alias ImportFrom alias ClassDef bases NameLoad body Assign NameStore NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad Str attr AttributeLoad Call NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad TupleLoad Str AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If CompareEq SubscriptLoad NameLoad Slice Num Str body Assign NameStore SubscriptLoad NameLoad Slice Num Assign NameStore Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad TupleLoad Str AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad orelse If CompareEq SubscriptLoad NameLoad Slice Num Str body Expr Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad decorator_list decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad keyword NameLoad keyword Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list decorator_list Assign NameStore Call AttributeLoad Call NameLoad attr
N/A N/A 
An example demonstrating how to send and receive UDP broadcast messages.

Every second, this application will send out a PING message with a unique ID.
It will respond to all PING messages with a PONG (including ones sent by
itself). You can tell how many copies of this script are running on the local
network by the number of "RECV PONG".

Run using twistd:

$ twistd -ny udpbroadcast.py
 uuid uuid4 twisted.application internet service twisted.internet.protocol DatagramProtocol twisted.python log PingPongProtocol N/A DatagramProtocol N/A N/A noisy False __init__ N/A N/A self controller port N/A N/A N/A N/A self port port N/A startProtocol N/A N/A self N/A N/A N/A N/A N/A N/A self transport setBroadcastAllowed True N/A sendPing N/A N/A self N/A N/A N/A pingMsg N/A N/A PING {0} format N/A N/A uuid4 hex N/A N/A N/A N/A self transport write pingMsg N/A <broadcast> N/A self port N/A N/A N/A log msg N/A SEND  pingMsg N/A datagramReceived N/A N/A self datagram addr N/A N/A N/A N/A N/A datagram N/A 4 PING N/A N/A uuid N/A datagram N/A 5 N/A pongMsg N/A N/A PONG {0} format uuid N/A N/A N/A N/A self transport write pongMsg N/A <broadcast> N/A self port N/A N/A N/A log msg N/A RECV  datagram N/A N/A N/A N/A datagram N/A 4 PONG N/A N/A N/A N/A log msg N/A RECV  datagram N/A N/A Broadcaster N/A object N/A ping N/A N/A self proto N/A N/A N/A N/A N/A proto sendPing N/A makeService N/A N/A self N/A N/A N/A application N/A N/A service Application Broadcaster N/A root N/A N/A service MultiService N/A N/A N/A root setServiceParent application N/A proto N/A PingPongProtocol controller self port 8555 N/A N/A N/A root addService N/A N/A internet UDPServer 8555 proto N/A N/A N/A root addService N/A N/A internet TimerService 1 N/A self ping proto N/A application N/A N/A N/A application N/A N/A N/A Broadcaster makeService