Created
July 14, 2015 10:36
-
-
Save zhangys-lucky/218a9d36c06b64abb00f to your computer and use it in GitHub Desktop.
python broadcast
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send UDP broadcast packets | |
MYPORT = 50000 | |
import sys, time | |
from socket import * | |
s = socket(AF_INET, SOCK_DGRAM) | |
s.bind(('', 0)) | |
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) | |
while 1: | |
data = repr(time.time()) + '\n' | |
s.sendto(data, ('192.168.1.255', MYPORT)) | |
time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment