[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Preemptive socket connection monitoring
I really don't know of any way to ensure a connection
has not dropped other than read / write and ack or
acknowledge.
I have had and still have issues with firewalls that
block and there is no way to tell if the connection is
made other than a timeout waiting for a response. I
have in some cases deployed 2 servers where you
actually build a tunnel (SSL in most cases) and 1
server acts as a client and pushes data and the other
performs tasks such as DB access and sending data back
to the client.
This scenario allowed for a custom ping operation
which could be set as a Timer type function in JAVA.
The ping method always expects the ack as return, but
this again is a simple read / write / ack. These
servers are using Threads and you also have the
ability to deploy these across an enterprise for
redundancy if needed.
I'm not sure if this helps for your situation.
+James P.
--- cfowler <cfowler@outpostsentinel.com> wrote:
> Maybe create a non-block read() class. Then it can
> fail out on socket
> error.
>
>
> On Thu, 2002-11-21 at 17:17, Gary Herndon wrote:
> > All,
> >
> > I am currently trying to come up with a good way
> to check the connection
> > behind a socket to make sure it hasn't been
> dropped. I would like to do
> > this without reading/writing the streams and
> catching the exception. My
> > current method of thinking was use the
> PushBackInputStream as a wrapper for
> > the Socket.getInputStream() and then attempt to
> read/unread 1 byte anytime I
> > wanted to know if the socket was up. If the
> socket was down, the read would
> > fail and I could return a FAIL, otherwise, I would
> just push the byte back
> > on the stream, and return a SUCCESS. (I haven't
> looked too much at Readers
> > since my data is not a character stream).
> >
> > I have 2 questions.
> > 1: Is this a good way to handle the problem?
> > 2: The problem I see with this method is that the
> isConnected() method I
> > write would block if there was no data on the
> InputStream... can this be
> > prevented?
> >
> > I imagine that all my problems would be solved
> with the java.nio of 1.4, but
> > currently I have to work on a 1.3 JVM, so please
> keep that in mind when
> > offering suggestions.
> >
> > Thanks,
> > Gary Herndon
> >
> >
> >
>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com