#NEWLINE# def test_multiListen( self ) : #NEWLINE# #INDENT# '\n        Test that multiple sockets can listen on the same multicast port and\n        that they both receive multicast messages directed to that address.\n        ' #NEWLINE# firstClient = Server ( ) #NEWLINE# firstPort = reactor . listenMulticast ( 0 , firstClient , listenMultiple = True ) #NEWLINE# portno = firstPort . getHost ( ) . port #NEWLINE# secondClient = Server ( ) #NEWLINE# secondPort = reactor . listenMulticast ( portno , secondClient , listenMultiple = True ) #NEWLINE# theGroup = '225.0.0.250' #NEWLINE# joined = gatherResults ( [ self . server . transport . joinGroup ( theGroup ) , firstPort . joinGroup ( theGroup ) , secondPort . joinGroup ( firstPort ) ] ) #NEWLINE# def serverJoined( ignored ) : #NEWLINE# #INDENT# d1 = firstClient . packetReceived = Deferred ( ) #NEWLINE# d2 = secondClient . packetReceived = Deferred ( ) #NEWLINE# firstClient . transport . write ( 'hello world' , ( theGroup , portno ) ) #NEWLINE# return gatherResults ( [ d1 , d2 ] ) #NEWLINE# #UNINDENT# joined . addCallback ( serverJoined ) #NEWLINE# def gotPackets( ignored ) : #NEWLINE# #INDENT# self . assertEqual ( firstClient . packets [ 0 ] [ 0 ] , 'hello world' ) #NEWLINE# self . assertEqual ( secondClient . packets [ 0 ] [ 0 ] , 'hello world' ) #NEWLINE# #UNINDENT# joined . addCallback ( gotPackets ) #NEWLINE# def cleanup( passthrough ) : #NEWLINE# #INDENT# result = gatherResults ( [ maybeDeferred ( firstPort . stopListening ) , maybeDeferred ( secondPort . stopListening ) ] ) #NEWLINE# result . addCallback ( ( lambda ign : passthrough ) ) #NEWLINE# return result #NEWLINE# #UNINDENT# joined . addBoth ( cleanup ) #NEWLINE# return joined