#NEWLINE# def test_multicast( self ) : #NEWLINE# #INDENT# '\n        Test that a multicast group can be joined and messages sent to and\n        received from it.\n        ' #NEWLINE# c = Server ( ) #NEWLINE# p = reactor . listenMulticast ( 0 , c ) #NEWLINE# addr = self . server . transport . getHost ( ) #NEWLINE# joined = self . server . transport . joinGroup ( '225.0.0.250' ) #NEWLINE# def cbJoined( ignored ) : #NEWLINE# #INDENT# d = self . server . packetReceived = Deferred ( ) #NEWLINE# c . transport . write ( 'hello world' , ( '225.0.0.250' , addr . port ) ) #NEWLINE# return d #NEWLINE# #UNINDENT# joined . addCallback ( cbJoined ) #NEWLINE# def cbPacket( ignored ) : #NEWLINE# #INDENT# self . assertEqual ( self . server . packets [ 0 ] [ 0 ] , 'hello world' ) #NEWLINE# #UNINDENT# joined . addCallback ( cbPacket ) #NEWLINE# def cleanup( passthrough ) : #NEWLINE# #INDENT# result = maybeDeferred ( p . stopListening ) #NEWLINE# result . addCallback ( ( lambda ign : passthrough ) ) #NEWLINE# return result #NEWLINE# #UNINDENT# joined . addCallback ( cleanup ) #NEWLINE# return joined