For testing I am using the loopback interface on the ESP32 (arduino-esp32 core). A server and a client are running in different tasks, the client connecting to the server. If the server disconnects, the client does not notice - the connected() call always will report the connection would be still established.
It took me a while to find that the client.connected() return value for the loopback connection seems to only be updated if an external connection from another client in the net is established or disconnected.
Is there any special treatment necessary, is it like that by design or am I completely wrong? I could not find any concise information about that yet.
Well, the first attempt was nothing elegant, I am afraid. I had another MCU connecting and disconnecting regularly over the network
The current solution was surprising, at least for me: if you do a WiFi.begin("foo", "bar"); with no real ssid and password, you still can use the loopback on 127.0.0.1 and now it is working.