From: Yohanes Santoso Date: 2005-07-08T06:03:59+09:00 Subject: Re: Socket Question - close Yohanes Santoso writes: > Detecting if the remote end has closed its side is not that > straight-forward. Let me add to the above statement. It is not straight forward for TCP connection. Other transport-level protocol may have other mechanism to reliably detect and indicate connection termination. Due to difficulty in detecting connection termination in TCP, app-level protocols running on top of TCP often has their own mechanisms: 1. Implicit termination signal, e.g. HTTP/1.0: you send a request, the server returns the length of a response and then the response itself. Both the client and server knows that after the response is done, the connection is considered terminated. 2. Explicit termination signal, e.g. FTP: the client must tell the server that the connection is going to be terminated immediately. 3. Timed termination signal: if there is no activity for a certain duration, the connection is considered terminated. Usually used in app-level time-out mechanism. YS.