I have 2 UDP responses to a destination ip, one right after the other:
sendsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sendsock.bind(('%s' % ip_adr, 1036))
#send first packet
ok_response = "Reception Success, more to come"
str2bytes = bytes(ok_response,'utf-8')
sendsock.sendto(str2bytes, ("%s" % phone.ip_addr, int(phone.sip_port)))
#send second packet
ok_response = "Fun data here"
str2bytes = bytes(ok_response,'utf-8')
sendsock.sendto(str2bytes, ("%s" % phone.ip_addr, int(phone.sip_port)))
I can see with Wireshark the second packet gets sent. But the first seems be ignored.
Unless someone can see a hiccup in my code, is there a way to do an if statement on each sendsock.sendto()
instance, to ensure the code doesn't continue until it's acknowledged as sent?
Also, should I be closing the sendsock?