Broadcast Sender : Socket Broadcast : Network PYTHON examples


PYTHON examples » Network » Socket Broadcast »

 

Broadcast Sender



import socket, sys
dest = ('<broadcast>', 51423)

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto("Hi", dest)
print "Looking for replies; press Ctrl-C to stop."
while 1:
    (buf, address= s.recvfrom(2048)
    if not len(buf):
        break
    print "Received from %s: %s" (address, buf)

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Network
» Socket Broadcast