Determining that all outbound packets are sent ...
Posted: Fri Nov 11, 2016 3:52 pm
Imagine I have an app that wishes to wake up, connect to an access point, send data and then disconnect from the access point. I am planning to use UDP datagram messages for transmission. In my logic I was coding:
My concern here is that it initially "appears" that when I issue esp_wifi_disconnect(), the outbound packets may not be being sent before the network connections are shutdown. If I change my logic to be:
I don't appear to have an issue. Should esp_wifi_disconnect() honor buffered transmissions before disconnecting? Is there some other logic that I should be using such as some kind of blocking flush() type API call?
Code: Select all
sendto(socket, ...); // Send the data gram packet
close(socket); // Close the socket
esp_wifi_disconnect(); // Disconnect from the access point
Code: Select all
sendto(socket, ...); // Send the data gram packet
close(socket); // Close the socket
sleep(1); // Sleep for a second
esp_wifi_disconnect(); // Disconnect from the access point