1 from twisted.internet.protocol import DatagramProtocol
\r
2 from twisted.internet import reactor
\r
5 class MulticastPingClient(DatagramProtocol):
\r
7 def startProtocol(self):
\r
8 # Join the multicast address, so we can receive replies:
\r
9 self.transport.joinGroup("228.0.0.5")
\r
10 # Send to 228.0.0.5:8005 - all listeners on the multicast address
\r
11 # (including us) will receive this message.
\r
12 self.transport.write('Client: Ping', ("228.0.0.5", 8005))
\r
14 def datagramReceived(self, datagram, address):
\r
15 print "Datagram %s received from %s" % (repr(datagram), repr(address))
\r
18 reactor.listenMulticast(8005, MulticastPingClient(), listenMultiple=True)
\r