E
Ed
Guys,
I am looking to read from a socket and keep reading until I receive a
certain set of characters. However in an "error" situation these
characters never arrive, the socket "dries up" and I need to be able
to spot this.
I have a loop as follows:
while((c = m_reader.read()) != -1)
{
message.append((char)c);
if (message.toString().endsWith(endOfResponseString))
{
break;
}
}
Obviously if the server misbehaves, the m_reader.read() blocks and
everything hangs.
What I want is some way of "timing out" the loop after a period of
inactivity.
The server is a remote IP server so a message can be sent in separate
"chunks". m_reader is a BufferedReader but that can be changed if it
helps achieve the desired affect.
Any ideas?
Cheers
Ed
I am looking to read from a socket and keep reading until I receive a
certain set of characters. However in an "error" situation these
characters never arrive, the socket "dries up" and I need to be able
to spot this.
I have a loop as follows:
while((c = m_reader.read()) != -1)
{
message.append((char)c);
if (message.toString().endsWith(endOfResponseString))
{
break;
}
}
Obviously if the server misbehaves, the m_reader.read() blocks and
everything hangs.
What I want is some way of "timing out" the loop after a period of
inactivity.
The server is a remote IP server so a message can be sent in separate
"chunks". m_reader is a BufferedReader but that can be changed if it
helps achieve the desired affect.
Any ideas?
Cheers
Ed