Reputation: 720
I intend to broadcast UDP strings to the local network, using Python. What is the most straightforward way of doing that?
Upvotes: 2
Views: 1108
Reputation: 21241
You can use socket
python module
Please see below code from UdpComminication wiki
import socket
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
MESSAGE = "Hello, World!"
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE.encode(), (UDP_IP, UDP_PORT))
Upvotes: 2