receive02.py

# =========================================================
# Receive UDP broadcast packets
#
# found here:
#       code.activestate.com/recipes/
#       577278-receive-udp-broadcasts/
# moved to:
#       github.com/ActiveState/code
#       (did not find the old code in github)
# =========================================================

import select, socket 

port = 10000  # where do you expect to get a msg?
bufferSize = 1024 # whatever you need

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('<broadcast>', port))
s.setblocking(0)

while True:
    result = select.select([s],[],[])
    msg = result[0][0].recv(bufferSize) 
    print(msg)