blob: 6d2b1e813f4833d241d1ef24f3a6b44a1ab5886a [file] [log] [blame]
Guido van Rossumb83ec8f1992-05-19 13:52:02 +00001# Send UDP broadcast packets
2
3MYPORT = 50000
4
5import sys, time
6from socket import *
7
8s = socket(AF_INET, SOCK_DGRAM)
Guido van Rossum00d59741994-10-08 19:13:48 +00009s.bind(('', 0))
Guido van Rossum0aead9f1992-09-08 21:20:12 +000010s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
Guido van Rossumb83ec8f1992-05-19 13:52:02 +000011
12while 1:
Tim Peterse6ddc8b2004-07-18 05:56:09 +000013 data = repr(time.time()) + '\n'
14 s.sendto(data, ('<broadcast>', MYPORT))
15 time.sleep(2)