Twisted Matrix and multicast broadcast

Discussion in 'Python' started by Stodge, Oct 9, 2008.

  1. Stodge

    Stodge Guest

    I'm trying to get a simple multicast application working using
    Twisted; so far I have:

    from twisted.internet.protocol import DatagramProtocol
    from twisted.internet import reactor
    from twisted.application.internet import MulticastServer

    class MulticastServerUDP(DatagramProtocol):
    def startProtocol(self):
    print 'Started Listening'
    # Join a specific multicast group, which is the IP we will
    respond to
    self.transport.joinGroup('224.0.0.1')

    def datagramReceived(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.listenMulticast(8005, MulticastServerUDP())
    reactor.run()


    and:



    from twisted.internet.protocol import DatagramProtocol
    from twisted.internet import reactor
    from twisted.application.internet import MulticastServer

    class MulticastClientUDP(DatagramProtocol):
    def startProtocol(self):
    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 datagramReceived(self, datagram, address):
    print "Received:" + repr(datagram)

    # Send multicast on 224.0.0.1:8005, on our dynamically allocated port
    reactor.listenMulticast(0, MulticastClientUDP())
    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
    Stodge, Oct 9, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jean-Paul Calderone
    Replies:
    0
    Views:
    444
    Jean-Paul Calderone
    Jun 17, 2008
  2. inorlando
    Replies:
    3
    Views:
    1,289
    castironpi
    Aug 29, 2008
  3. Jean-Paul Calderone

    Re: Twisted Matrix and multicast broadcast

    Jean-Paul Calderone, Oct 9, 2008, in forum: Python
    Replies:
    1
    Views:
    371
    Stodge
    Oct 9, 2008
  4. Glyph
    Replies:
    0
    Views:
    173
    Glyph
    Dec 27, 2012
  5. Glyph
    Replies:
    0
    Views:
    149
    Glyph
    Apr 3, 2013
Loading...

Share This Page