exception - Java disable stack trace on a specific call? -
i want disable 1 error message produces socket timeout, because it's filling console (linux, terminal).
the code:
public threadlistenresponsequery(datagramsocket socket){ this.socket = socket; try { socket.setsotimeout(1500); } catch (socketexception e) { // todo auto-generated catch block e.printstacktrace(); } } @override public void run(){ system.out.println("waiting response..."); // waiting 60 seconds... while(system.currenttimemillis() < starttime + 60000){ socket.receive(receive_packet); // .. additional work } }
the program waiting 60 seconds response. setting timeout on socket because while
cycle freezing out if no response message coming.
error:
java.net.sockettimeoutexception: receive timed out @ java.net.dualstackplaindatagramsocketimpl.socketreceiveorpeekdata(native method) @ java.net.dualstackplaindatagramsocketimpl.receive0(unknown source) @ java.net.abstractplaindatagramsocketimpl.receive(unknown source) @ java.net.datagramsocket.receive(unknown source) @ thread.threadlistenresponsequery.run(threadlistenresponsequery.java:46) @ java.lang.thread.run(unknown source)
surround socket.receive
try-catch
:
try { socket.receive() } catch (sockettimeoutexception e) { // log error, abort communication, or ignore }
Comments
Post a Comment