mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
unicast pendant for broadcast.py
This commit is contained in:
parent
171191efb2
commit
4ec060ad28
1 changed files with 16 additions and 0 deletions
16
Demo/sockets/unicast.py
Normal file
16
Demo/sockets/unicast.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Send UDP broadcast packets
|
||||
|
||||
MYPORT = 50000
|
||||
|
||||
import sys, time
|
||||
from socket import *
|
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM)
|
||||
s.bind(('', 0))
|
||||
|
||||
while 1:
|
||||
data = `time.time()` + '\n'
|
||||
s.sendto(data, ('', MYPORT))
|
||||
time.sleep(2)
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue