Re: Is it possible to detect TCP session term without reading pending data?
From: Andrei Voropaev (avorop_at_mail.ru)
Date: 04/16/04
- Next message: Andrei Voropaev: "Re: Multi instances, threads, tasks and sockets question."
- Previous message: Florian Zschocke: "Multi instances, threads, tasks and sockets question."
- Next in thread: aprotopa: "Re: Is it possible to detect TCP session term without reading pending data?"
- Maybe reply: aprotopa: "Re: Is it possible to detect TCP session term without reading pending data?"
- Reply: Darko M.: "Re: Is it possible to detect TCP session term without reading pending data?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Apr 2004 07:25:53 GMT
On 2004-04-15, aprotopa <aprotopapas@yahoo.com> wrote:
> Hi all -
> I have an application which should only read from a TCP socket if
> condition X is true. But the application should also be able to
> detect if the TCP peer closed the connection from his side.
> The problem happens when condition X is false while the peer
> terminates the connection, but there is data pending to be read on the
> socket. In that case, poll() becomes useless to me because it only
> tells me that there is data to read, not that the connection has been
> terminated.
> Does anyone know a usage of poll() or some other system function
> that would give the application the ability to detect the closed
> connection in this special case?
> I work mostly on Solaris, but ideally I would like to find a
> portable solution to this problem.
Really, it all depends on your specific situation. For example, if you
still write while your X is false, then after your peer has closed
connection 'send' shall return EPIPE (of course if you use MSG_NOSIGNAL
flag). Also poll may set POLLHUP flag. If your application does not
write and your X might be false for long time, then it's better to read
from socket and discard incoming data (your protocol allows discarding,
right ? :)
Andrei
- Next message: Andrei Voropaev: "Re: Multi instances, threads, tasks and sockets question."
- Previous message: Florian Zschocke: "Multi instances, threads, tasks and sockets question."
- Next in thread: aprotopa: "Re: Is it possible to detect TCP session term without reading pending data?"
- Maybe reply: aprotopa: "Re: Is it possible to detect TCP session term without reading pending data?"
- Reply: Darko M.: "Re: Is it possible to detect TCP session term without reading pending data?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|