I am using python to create a UDP client to broadcast messages as per code below. this works as expected. however when the network is down, I would still like the server running on the localhost to receive the UDP packets. any way this can be done.
try:
s1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s1.bind(('', 0))
s1.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
except socket.error:
print 'Failed to create socket'
I put the following in a loop
try:
s1.sendto(msg, ('<broadcast>', port))
except:
print 'Failed to sent message'