I made an experiment:
A server listens on port 8804 accepts a connection of a client and then send data to the client endless. I shutdown the network.
- When I run netstat -anotp | grep 8804 ,it shows that the connection is “ESTABLISHED” on both server and client , but there is no data transmission.
- After a while , the server throw an error : “Connection time out”
- netstat -anotp | grep 8804 and found that the client is still “ESTABLISHED”
So:
1. Why does the server which is blocked on the system call “write” throw the “Connection timeout” error. Why not the client ?
2. How to let the client find the connection is shutdown actually.
3. Why are the server and client’s statuses both “ESTABLISHED” when the network does not work ?
Thanks for your answer !
s):EDIT:
Since you’re using C, a link to the Linux TCP Keepalives Howto
NOTES