Created
November 18, 2018 18:18
-
-
Save EbbeVang/33ee44637157fd49e3a70eb0ff901451 to your computer and use it in GitHub Desktop.
This file contains 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
BROADCAST_TO_PORT = 7000 | |
import time | |
from socket import * | |
from datetime import datetime | |
s = socket(AF_INET, SOCK_DGRAM) | |
#s.bind(('', 14593)) # (ip, port) | |
# no explicit bind: will bind to default IP + random port | |
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) | |
while True: | |
data = "Current time " + str(datetime.now()) | |
s.sendto(bytes(data, "UTF-8"), ('<broadcast>', BROADCAST_TO_PORT)) | |
print(data) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment