Last active
December 16, 2018 21:34
-
-
Save DesignA-Electronics/b1ff0f18fb069f7946bebaf3614cc4df to your computer and use it in GitHub Desktop.
Python example of UDP Broadcast packet transmission
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
| #!/usr/bin/env python | |
| import socket | |
| import time | |
| if __name__ == '__main__': | |
| UDP_IP = "10.255.255.255" | |
| UDP_PORT = 12345 | |
| MESSAGE = "KEEP ALIVE" | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
| while True: | |
| sock.sendto(MESSAGE, (UDP_IP, UDP_PORT)) | |
| time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment