How to determine lost socket connection
Hi, All.
I am a new Linux programmer.
I made a Linux TCP server for control applications. When some TCP client
connects to it, the program goes into infinite console loop, getting characters, echoing them to client, parsing commands etc. Everything is OK until the client unexpectedly terminates the connection. I have to detect this event inside the loop and break. I thought that it might be done by analyzing socket state (i.e. if the state is not ESTABLISHED - break the loop) but from various examples and HOWTOs I did not see how to do it. It seems that I have to solve this problem in different way.
Can anybody criticize and prompt?
|