I am trying to write a simple messenger that sends a broadcast msg to all the computer in the local network . The code works on windows 7 , Ubuntu 14.10 but when I am trying to use it on windows 10 , it even does not send an udp package to broadcast , its doing nothing (checked with wireshark, no outgoing packages)
import socket
import sys
import traceback
dest=('<broadcast>',10100)
UDPSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
UDPSock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
while True:
data = raw_input("Enter message to send or type 'exit': ")
UDPSock.sendto(data, dest)
if data == "exit":
break
UDPSock.close()
I recognized the same problem after updating to Win10. My WOL.py (Wakeup On Lan) does not work any more. Checked with tcpdump.
I found now a workaround.
# Broadcast it to the LAN.
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.sendto(send_data, ('172.16.1.255', 9)
Changing the address from '<broadcast>'
to the network address with broadcast bit's set works on my system.
E.g. I have a Class C Network with IP 172.16.1.x netmask 255.255.255.0. Changing '<broadcast>'
to '172.16.1.255'
does the trick. Normally this is done by the OS.
PS.: Sorry for the wrong posting, last time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With