Skip to main content
added 235 characters in body
Source Link
YuTendo
  • 339
  • 3
  • 15

However, if you want to limit also the time for reading the inputstream without throwing an exception, then you need a costum solution: Is it possible to read from a InputStream with a timeout?

The following running example worked very well in my local network. It tried to connect for at most three seconds and detected all running webservers.

The following running example worked very well in my local network. It tried to connect for at most three seconds and detected all running webservers.

However, if you want to limit also the time for reading the inputstream without throwing an exception, then you need a costum solution: Is it possible to read from a InputStream with a timeout?

The following running example worked very well in my local network. It tried to connect for at most three seconds and detected all running webservers.

added 136 characters in body
Source Link
YuTendo
  • 339
  • 3
  • 15

where target is any IP address. The following line essentially set the timeout value for reading/waiting for the inputstream -after the connection was established. So it has not effect on establishing the connection itself. However, after the connection was established it would interrupt the "read inputstream" step after three seconds (by throwing an exception).

where target is any IP address. The following line essentially set the timeout value for reading/waiting for the inputstream -after the connection was established. So it has not effect on establishing the connection itself.

where target is any IP address. The following line essentially set the timeout value for reading/waiting for the inputstream -after the connection was established. So it has not effect on establishing the connection itself. However, after the connection was established it would interrupt the "read inputstream" step after three seconds (by throwing an exception).

deleted 64 characters in body
Source Link
YuTendo
  • 339
  • 3
  • 15

The following running example worked very well in my local network. It tried to connect for at most three seconds and detected all running webservers. I removed the line with setSoTimeout as I don't see the need.

The following running example worked very well in my local network. It tried to connect for at most three seconds and detected all running webservers. I removed the line with setSoTimeout as I don't see the need.

The following running example worked very well in my local network. It tried to connect for at most three seconds and detected all running webservers.

Source Link
YuTendo
  • 339
  • 3
  • 15
Loading