old_contents: from twisted.internet.protocol import DatagramProtocol
  from twisted.internet import reactor
  from twisted.application.internet import MulticastServer
  
  class MulticastClientUDP(DatagramProtocol):
  
      def datagramReceived(self, datagram, address):
              print "Received:" + repr(datagram)
  
  # Send multicast on 224.0.0.1:8005, on our dynamically allocated port
  # the listener
  if __name__ == '__main__':
      reactor.listenUDP(0, MulticastClientUDP()).write('UniqueID', ('224.0.0.1', 8005))
      reactor.run()
  
new_contents: from twisted.internet.protocol import DatagramProtocol
  from twisted.internet import reactor
  from twisted.application.internet import MulticastServer
  
  class MulticastClientUDP(DatagramProtocol):
  
      def datagramReceived(self, datagram, address):
              print "Received:" + repr(datagram)
  
  # Send multicast on 224.0.0.1:8005, on our dynamically allocated port
  # the listener
  def main():
      reactor.listenUDP(0, MulticastClientUDP()).write('UniqueID', ('224.0.0.1', 8005))
      reactor.run()
  
  if __name__ == '__main__':
      main()
  
subject: move startup in to a main method