3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-23 23:55:48 +00:00

Set IRC discovery so timeout. Resolves issue 269.

This commit is contained in:
Mike Hearn 2013-01-29 16:20:50 +01:00
parent 590d47f273
commit 7108751d3c

View File

@ -97,11 +97,12 @@ public class IrcDiscovery implements PeerDiscovery {
int ipCursor = ipCursorStart; int ipCursor = ipCursorStart;
do { do {
connection = new Socket(); connection = new Socket();
int timeoutMsec = (int) TimeUnit.MILLISECONDS.convert(timeoutValue, timeoutUnit);
connection.setSoTimeout(timeoutMsec);
try { try {
InetAddress ip = ips[ipCursor]; InetAddress ip = ips[ipCursor];
long timeoutMsec = TimeUnit.MILLISECONDS.convert(timeoutValue, timeoutUnit);
log.info("Connecting to IRC with " + ip); log.info("Connecting to IRC with " + ip);
connection.connect(new InetSocketAddress(ip, port), (int)timeoutMsec); connection.connect(new InetSocketAddress(ip, port), timeoutMsec);
} catch (SocketTimeoutException e) { } catch (SocketTimeoutException e) {
connection = null; connection = null;
} catch (IOException e) { } catch (IOException e) {