java - InputStream Non Blocking read operation -


i have scenario need confirm either server side socket closed connection or not.so checking if(in.read() ==-1) if true ,it means server side closed connection. problem if not blocks here blocking call.i need such solution can read non blocking in perticular time or cancel reading if server end closed connection. creating

socket = new socket();                  // if server not available 3 seconds blocking call other wise exception                  socket.connect(new inetsocketaddress(serveraddress , serverport),3000); 

any appreciated.

regards, aamir

but problem if not blocks here blocking call.

that's not problem. there miuch bigger problem: throw away byte of data if data ever arrives. cannot that.

what need timed read. see socket.setsotimeout().


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -