Ivan,
My thought is that this general type of problem is solved by defining a protocol for the conversation. If you want to know if your client is [still] listening, send a challenge that it must answer.
Christian Werner
-----Original Message-----
From: Ivan Heffner [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 20, 2005 11:34 AM
To: modperl@perl.apache.org
Cc: Foo Ji- [EMAIL PROTECTED]
Subject: Re: How do I check a socket to know it is not closed?
I'm not sure I was clear enough with my original question, so I am
going to restate it.
I have a custom Apache Connection handler. It grabs the socket from
the Apache2::Connection object. It then reads a message from the
socket (this is working correctly) and then goes off and does some
work. When the work is finished, the handler needs to make sure that
the client is still listening on the other end of the socket before
sending the response.
This is important because part of the message that gets sent back
absolutely must be received by a listening process. If no one is
listening, I am going to buffer that part of the message and hang on
to it until I'm reasonably sure that I can send the message to a
listening process.
I want to reiterate that I am not having a problem reading from the
socket. I am having a problem with knowing that there is someone
listening to me when I start talking back.
Checking to see if the connection has aborted did not seem to work.
Polling the socket did not seem to tell me anything useful either.
I have attached my connection handler. This code does not detect when
I disconnect the connection from the client end. (I am using netcat to
test this.)
Thanks,
Ivan