title: Broadcasting and receiving data with Python
body: <p>I'm trying to broadcast some data and received it using python.
  This is the code that I came up with.</p>
  
  <pre><code>from socket import *
  import threading
  
  class PingerThread (threading.Thread):
      def __init__(self):
          threading.Thread.__init__(self)
  
      def run (self):
          print 'start thread'
          cs = socket(AF_INET, SOCK_DGRAM)
          cs.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
          cs.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
          cs.sendto('This is a test', ('192.168.65.255', 4499))
  
  a = PingerThread() 
  a.start()
  
  cs = socket(AF_INET, SOCK_DGRAM)
  data = cs.recvfrom(1024) # &lt;-- waiting forever
  </code></pre>
  
  <p>However, the code seems to wait forever at <code>cs.recvfrom(1024)</code>. What might be wrong?</p>