SocketWrapper library: MbedClient.connected() returns false even data are still available to read. The Client `connected()` method is documented as > Whether or not the client is connected. Note that a client is considered connected if the connection has been closed but there is still unread data. from https://www.arduino.cc/reference/en/libraries/ethernet/client.connected/ or https://www.arduino.cc/reference/en/libraries/wifi/client.connected/