Hello
This is my code for connecting to a multicast server, is this the best way of handling the exception. What I would like to do is to retry to connect if an exception occurs
def initialiseMulticastTrackerComms():
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 32)
sock.bind((ANY, MCAST_PORT))
host = socket.gethostbyname(socket.gethostname())
sock.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP,socket.inet_aton(MCAST_GRP) + socket.inet_aton(host))
sock.setblocking(False)
except socket.error, (value,message):
print "Could not open socket: " + message
sys.exit(1)
else:
print 'Connected to multicast server'
return sock
Could someone offer any advice on how to do this
Thanks in advance