I'm trying to get a simple multicast application working using
Twisted; so far I have:
from twisted.interne t.protocol import DatagramProtoco l
from twisted.interne t import reactor
from twisted.applica tion.internet import MulticastServer
class MulticastServer UDP(DatagramPro tocol):
def startProtocol(s elf):
print 'Started Listening'
# Join a specific multicast group, which is the IP we will
respond to
self.transport. joinGroup('224. 0.0.1')
def datagramReceive d(self, datagram, address):
# The uniqueID check is to ensure we only service requests
from
# ourselves
if datagram == 'UniqueID':
print "Server Received: " + repr(datagram)
self.transport. write("data", address)
# Listen for multicast on 224.0.0.1:8005
reactor.listenM ulticast(8005, MulticastServer UDP())
reactor.run()
and:
from twisted.interne t.protocol import DatagramProtoco l
from twisted.interne t import reactor
from twisted.applica tion.internet import MulticastServer
class MulticastClient UDP(DatagramPro tocol):
def startProtocol(s elf):
print 'Started Listening'
# Join a specific multicast group, which is the IP we will
respond to
self.transport. joinGroup('224. 0.0.1')
self.transport. write('UniqueID ',('224.0.0.1', 8005))
def datagramReceive d(self, datagram, address):
print "Received:" + repr(datagram)
# Send multicast on 224.0.0.1:8005, on our dynamically allocated port
reactor.listenM ulticast(0, MulticastClient UDP())
reactor.run()
*************** *************** *************** *************** *************** *********
No surprises there! But how do I get the server to send to all clients
using multicast? transport.write requires an address. Any suggestions
appreciated.
Thanks
Twisted; so far I have:
from twisted.interne t.protocol import DatagramProtoco l
from twisted.interne t import reactor
from twisted.applica tion.internet import MulticastServer
class MulticastServer UDP(DatagramPro tocol):
def startProtocol(s elf):
print 'Started Listening'
# Join a specific multicast group, which is the IP we will
respond to
self.transport. joinGroup('224. 0.0.1')
def datagramReceive d(self, datagram, address):
# The uniqueID check is to ensure we only service requests
from
# ourselves
if datagram == 'UniqueID':
print "Server Received: " + repr(datagram)
self.transport. write("data", address)
# Listen for multicast on 224.0.0.1:8005
reactor.listenM ulticast(8005, MulticastServer UDP())
reactor.run()
and:
from twisted.interne t.protocol import DatagramProtoco l
from twisted.interne t import reactor
from twisted.applica tion.internet import MulticastServer
class MulticastClient UDP(DatagramPro tocol):
def startProtocol(s elf):
print 'Started Listening'
# Join a specific multicast group, which is the IP we will
respond to
self.transport. joinGroup('224. 0.0.1')
self.transport. write('UniqueID ',('224.0.0.1', 8005))
def datagramReceive d(self, datagram, address):
print "Received:" + repr(datagram)
# Send multicast on 224.0.0.1:8005, on our dynamically allocated port
reactor.listenM ulticast(0, MulticastClient UDP())
reactor.run()
*************** *************** *************** *************** *************** *********
No surprises there! But how do I get the server to send to all clients
using multicast? transport.write requires an address. Any suggestions
appreciated.
Thanks