How to determine terminated TCP connection in Linux?

From: Alexander Baranov (baranov_at_intech21.com)
Date: 09/24/04


Date: Fri, 24 Sep 2004 10:47:53 -0400

Hi, All.
I am a new Linux programmer.
I made a Linux TCP server for control applications. When some TCP client
connects to it, 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?
Regards, Alex.



Relevant Pages

  • Re: getting a threads state and CPU utilization
    ... of CPU time currently being used)? ... How could you tell an infinite loop from a polling loop ... responding to continuous messages from many client apps, ... though the customer *claims* that the client app is disconnecting (I suspect ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Is Message passing good approach for multi-threaded applications?
    ... that it's hard to even create an artificial case where select loop is ... client gets to wait while each file read for that client blocks. ... And never ever blocking on pain of death doesn't introduce overhead ... This is from lots of painful experience. ...
    (comp.unix.programmer)
  • Re: OnPaint, SetWindowPos and recursion
    ... if the client area is smaller than the window size, he'll never get anything to fit so it ... size and the client size will be different. ... I call SetWindowPos but when I do that I enter an infinite loop and my ... csText = csText.Mid; ...
    (microsoft.public.vc.mfc)
  • Re: One-way transmission on a T3
    ... to a hard loop at the handoff. ... I continue to suggest to the client that the problem is in the cloud, ... DS3 pre-equalizer build out in the MUX equipment at your end may be too ... cables that support DS3 services. ...
    (comp.dcom.telecom.tech)
  • Re: multiple tcp server and client execution with close problem
    ... while loop to accept ... Why is theserverstill waiting for the client? ... The server is still waiting because there is another function calling ...
    (comp.unix.programmer)