java - Unable to catch SocketTimeoutExeption -


i attempting catch sockettimeoutexception socket remains active , can continue reading through program. unfortunately, no matter how attempt catch read timeout can't , therefore application closes.

i have socket , setsotimeout 30000.

i call input.readline() , want catch timeout , continue. appreciated.

string response; try {         response = input.readline();         system.out.println("server response: " + response);         return; } catch(assertionerror e){     //we timed out. print user timeout occured,     //try command again     system.out.println("timeout: please try command again.\n"         + "if created game, join existing or create again."); } catch (sockettimeoutexception e) {     //we timed out. print user timeout occured,     //try command again     system.out.println("timeout: please try command again.\n"         + "if created game, join existing or create again."); } catch (ioexception ex) { //do nothing } 

the output is:

java.net.sockettimeoutexception: read timed out @ java.net.socketinputstream.socketread0(native method) @ java.net.socketinputstream.read(socketinputstream.java:150) @ java.net.socketinputstream.read(socketinputstream.java:121) @ sun.nio.cs.streamdecoder.readbytes(streamdecoder.java:284) @ sun.nio.cs.streamdecoder.implread(streamdecoder.java:326) @ sun.nio.cs.streamdecoder.read(streamdecoder.java:178) @ java.io.inputstreamreader.read(inputstreamreader.java:184) @ java.io.bufferedreader.fill(bufferedreader.java:161) @ java.io.bufferedreader.readline(bufferedreader.java:324) @ java.io.bufferedreader.readline(bufferedreader.java:389) @ client.main(client.java:97) 

either isn't real code, have own sockettimeoutexception class somewhere, or you've imported wrong one. suggest put useful catch ioexception block. might surprise.

why you're catching assertionerror , treating timeout mystery me.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -