I have a problem where I set the timeout of 0.5 seconds to setSoTimeout (500)
Is used to read the connection over time and time, but it is not really working and instead of 10 seconds later it usually happens with such an exception. And yes, in this situation the IP is valid.
java.net.ConnectException: Connection timed out: Connect
Here is the code:
Try {Socket Sock = New Socket (IP, 42042); Sock.setSoTimeout (500); BufferedInputStream = New BufferedInputStream (sock.getInputStream ()); TheNames = the names + is.read () + ";"; PrintWriter OS = new printwire (sock.getOutputStream ()); } Catch (IOE EXPRESS E) {System.out.println (E + "Provides a service" + IP + "no reponds pas."); }
socketsetset timeout
sets a reading timeout is. It has nothing to do with connect timeout if you want to reduce the default connect timeout: socket sock = new socket (); Sock.connect (new InetSocketAddress (IP, 42042), timeout);
Where is out of date
in millisecond.
Note: 'A timeout for zero is interpreted as an endless time end,' but it is not correct: it is defined as the platform's default connect timeout, Which is around a minute. Infinite timeout is applicable for reading, also note that you can use <0> less than >> to define platform defaults, but it increases can not.
Half a second is too short to connect timeout or to finish reading time.
No comments:
Post a Comment