Hi!
I'm trying to do a network broadcast so that a client can locate a service on a remote machine without having to tell it what the server host is.
I'm following this example:
http://www.java2s.com/Code/Python/Ne...castSender.htm
with strace, I can see this:
Code:
sendto(3, "exit"..., 4, 0, {sa_family=AF_INET, sin_port=htons(9000), sin_addr=inet_addr("255.255.255.255")}, 16) = 4
poll([{fd=3, events=POLLIN}], 1, 10000) = 0 (Timeout)
However, I'm checking with netstat and lsof to see if there's a process trying to connect to port 9000 and there's nothing of that. ALso, I can't see any traffic going out to port 9000 on any interface (either loopback or ethernet). What am I doing wrong?
Here's the offending code:
Code:
SERVICE_PORT = 9000
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.setblocking(True)
sock.settimeout(10) # 5-second timeout to detect the service
sock.sendto("exit", ('<broadcast>', SERVICE_PORT))
server = 0
try:
buff, server = sock.recvfrom(2048)
except:
# probably, timed out
print "Couldn't find registration service"
exit(-1)