mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Initial revision
This commit is contained in:
parent
c99a4f900d
commit
b83ec8f58d
5 changed files with 243 additions and 0 deletions
17
Demo/sockets/broadcast.py
Executable file
17
Demo/sockets/broadcast.py
Executable file
|
@ -0,0 +1,17 @@
|
|||
# Send UDP broadcast packets
|
||||
|
||||
MYPORT = 50000
|
||||
|
||||
import sys, time
|
||||
from socket import *
|
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM)
|
||||
s.bind('', 0)
|
||||
s.allowbroadcast(1)
|
||||
|
||||
while 1:
|
||||
data = `time.time()` + '\n'
|
||||
s.sendto(data, ('<broadcast>', MYPORT))
|
||||
time.sleep(2)
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue