I want to send a command to a server, and find out if I get a response.
Right now i am using BufferedReader
's readline()
function, which blocks until there's a response from server, but all I want to do is verify that there's a response from the server in the first place.
I tried using ready()
or reset()
to avoid this block, but it doesn't help.
This is causing my program to get stuck waiting for the server to respond, which never happens. InputStreamReader
seems to do the same thing, by my understanding of things.
Other questions I found here on the subject didn't answer my question, so please if you can answer my question it will be great.
May be all you need is the InputStream
without wrapping it in a BufferedReader
while (inputStream.available() > 0) {
int i = inputStream.read(tmp, 0, 1024);
if (i < 0)
break;
strBuff.append(new String(tmp, 0, i));
}
I hope this helps.