2022-11-14 09:24 AM
Hello,
I am using STM32H743 and imported the sample project LwIP_HTTP_Server_Netconn_RTOS. Is there anyway to indicate the TCPIP is still alive or not in case the ethernet cable is disconnected?
Thanks
2022-11-14 04:59 PM
The TCP connection connected until it is... disconnected. The Ethernet link state is not directly related to TCP connection state and it doesn't tell anything about whether the other IP device is reachable. For that purpose sometimes ICMP ping can be used.
2022-11-15 09:10 AM
Thank you for your answer.
Do you mean to send ping from the client to the STM TCPIP server? This doesn't work to me because I need the STM to detect the disconnection itself so that it can shut off some functions. Do you have any idea about it?
Thanks.
2022-11-15 11:24 AM
In err.h, there are many error status such as
/** Not connected. */
ERR_CONN
/** Connection aborted. */
ERR_ABRT = -13,
/** Connection reset. */
ERR_RST = -14,
/** Connection closed. */
ERR_CLSD
When the connection is disconnected by client, the ERR_CLSD is returned. However, there is nothing returned when the connection is disconnected by unplug the ethernet.
2022-11-15 02:29 PM
Disconnection is done at physical level, TCP is a protocol at a very higher level. TCP is not aware of physical state and can't report this information. You have to check at physical level for disconnection (Looks like there is a callback for this)
2022-11-15 04:06 PM
> send ping from the client to the STM TCPIP server? This doesn't work to me
Ping is not related to your TCP connection and can be sent by both sides.
> I need the STM to detect the disconnection itself so that it can shut off some functions
Disconnection of what? Ethernet link or TCP connection?
> there is nothing returned when the connection is disconnected by unplug the ethernet
Ethernet link state is managed by a code that is not related to TCP in any way and is detected almost immediately. On the other hand, TCP connection will time out only after 2 hours.
2022-11-15 06:16 PM
Hello Piranha,
It should be the disconnection of the ethernet link. I can get the TCP disconnected with no problem and the ERR_CLSD is returned right away when the client close the TCP connection. However, if I unplug the ethernet cable intentionally, no status is returned even there is no ERR_CLSD. So I would like the STM to detect this kind of disconnection. Thanks for you help.
Andy