How detect disconnect in tcpsocket?


How can I know if the server crashes when implementing the client via tcpsocket?



Method socket::connect returns a state nsapi_error_t. So when you will call this method and check the error according to this - Mbed OS Reference | TCPSocket Class Reference

BR, Jan

it is only possible to check in the application layer by adding something like a watchdog. A TCP connection can be phyically broken and works again after long long time when reconnected.
The sender can detect a missing ACK, but the receiver can never detect it. Expept you define a message that the receiver expects cyclic. A built in option for this is tcp_keepalive, this should be support in mbed and the underlying lwip stack.