Scan all addresses

pull/159/head
M66B 5 years ago
parent d7d00556b9
commit 4a72f7ff90

@ -418,9 +418,16 @@ public class EmailProvider {
@Override @Override
public Boolean call() { public Boolean call() {
try (Socket socket = new Socket()) { try (Socket socket = new Socket()) {
InetAddress iaddr = InetAddress.getByName(host); InetAddress[] iaddr = InetAddress.getAllByName(host);
InetSocketAddress inetSocketAddress = new InetSocketAddress(iaddr, Server.this.port); for (int i = 0; i < iaddr.length; i++)
try {
Log.i("Connecting to " + iaddr[i]);
InetSocketAddress inetSocketAddress = new InetSocketAddress(iaddr[i], Server.this.port);
socket.connect(inetSocketAddress, DNS_TIMEOUT); socket.connect(inetSocketAddress, DNS_TIMEOUT);
} catch (Throwable ex) {
if (i + 1 == iaddr.length)
throw ex;
}
Log.i("Reachable " + Server.this); Log.i("Reachable " + Server.this);
return true; return true;
} catch (IOException ex) { } catch (IOException ex) {

Loading…
Cancel
Save