Created
March 16, 2020 23:52
-
-
Save DirkHoffmann/bfec0e1c242eb92450c0b0af03c91291 to your computer and use it in GitHub Desktop.
UDP broadcast with python
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 python3 | |
# -*- coding: utf-8 -*- | |
# Copyright © Dirk Hoffmann -CPPM-, 2020 | |
import socket | |
UDP_IP = "255.255.255.255" | |
UDP_PORT = 60000 | |
msg = bytearray.fromhex('7effff0111000000000000000000000000000000000000000000000000000010020d') | |
print("UDP target IP:", UDP_IP) | |
print("UDP target port:", UDP_PORT) | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) # UDP | |
#sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 20) | |
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
#sock.bind(('', UDP_PORT)) | |
for port in range(50000,65000): | |
sock.sendto(msg, (UDP_IP, port)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment