I've been testing blocking sockets on the ESP8266. If the WiFi fails completely the socket (correctly) throws an OSError which can be trapped. However I've experienced rare conditions where the WiFi link is degraded by virtue of distance and/or RF interference where the socket read and write methods can block for long periods - possibly in some circumstances indefinitely. Usually it clears in a few seconds or tens of seconds but I encountered one which only ended when I hit <ctrl>C to discover the cause (socket.write).
Clearly this can't be trapped and will cause an application hang.
Two questions:
- Is this expected behaviour? I suspect it's inevitable.
- If so, should blocking sockets be used? A socket timeout is the obvious (and tested) fix.