Created
January 19, 2019 17:09
-
-
Save ttofis/7eaa9d849abd2f7f01ba602f35edd7d0 to your computer and use it in GitHub Desktop.
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
from socket import * | |
import ipaddress | |
#ip = ((([ip for ip in gethostbyname_ex(gethostname())[2] if not ip.startswith("127.")] or [[(s.connect(("8.8.8.8", 53)), s.getsockname()[0], s.close()) for s in [socket(AF_INET, SOCK_DGRAM)]][0][1]]) + ["no IP found"])[0]) | |
#ipad = ipaddress.ip_address(ip) | |
#print (ipad) | |
ip = "255.255.255.255" | |
UDP_PORT = 5005 | |
MESSAGE = b'Hello, World!' | |
print ("UDP target IP:", ip) | |
print ("UDP target port:", UDP_PORT) | |
print ("message:", MESSAGE) | |
cs = socket(AF_INET, SOCK_DGRAM) | |
cs.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) | |
cs.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) | |
cs.sendto(MESSAGE, (ip, UDP_PORT)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment