I am trying to sort through a list of SOCKS proxies, and figure out which ones have a connect and read time of less than 1000ms, here is my code
for(Proxy p : proxies) {
try {
URLConnection testConnection = testUrl.openConnection(p);
testConnection.setConnectTimeout(TIMEOUT_VALUE);
testConnection.setReadTimeout(TIMEOUT_VALUE);
success.add(p);
} catch(SocketTimeoutException ste) {
System.out.println("Proxy " + p.address().toString() + " timed out.");
}
}
But every single one of them passes the test, even when I do TIMEOUT_VALUE = 1;
What am I doing wrong? Thanks for any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…