Hello there…
i am having problem with detecting unplugged LAN cable.
i read that i must turn on the keep alive timer, so if the remote client/server doesnt reply when keep alive timer send 1 byte data, W5500 will generate timeout interrupt, and then i can close the socket.
And then i found something weird. I did 3 type of testing. the result is:
TESTING 1
- set socket 0 to TCP server
- socket 0 OPEN
- set keep alive timer to 1 (5 secs)
- socket 0 LISTEN
- remote TCP Client connecting to W5500
- connected, socket status become 0x17
- TCP client send some data, received normally by W5500
- and then i unplugged the LAN cable
- after some time, socket TIMEOUT occurs (as expected)
- socket 0 closed, back to point 2
TESTING 2
- set socket 0 to TCP server
- socket 0 OPEN
- set keep alive timer to 1 (5 secs)
- socket 0 LISTEN
- remote TCP Client connecting to W5500
- connected, socket status become 0x17
- W5500 send some data, received normally by remote TCP client
- and then i unplugged the LAN cable
- after some time, socket TIMEOUT occurs (as expected)
- socket 0 closed, back to point 2
TESTING 3
- set socket 0 to TCP server
- socket 0 OPEN
- set keep alive timer to 1 (5 secs)
- socket 0 LISTEN
- remote TCP Client connecting to W5500
- connected, socket status become 0x17
- do nothing
- and then i unplugged the LAN cable
- i waited, but no timeout at all.
i am confused about TESTING 3. do i have to send/receive data first, so the timeout will occur? or there is another way to detect unplugged cable?