Skip to content

Instantly share code, notes, and snippets.

@josemmo
Created March 28, 2018 09:23
Show Gist options
  • Save josemmo/7d982a32c4a96b529572c1557c3f947b to your computer and use it in GitHub Desktop.
Save josemmo/7d982a32c4a96b529572c1557c3f947b to your computer and use it in GitHub Desktop.
private void connectToServer(InetAddress ip) {
try {
Socket s = new Socket();
s.connect(
new InetSocketAddress(ip, Cutrecoin.PORT),
Cutrecoin.TIMEOUT
);
s.close();
// Añadir a la lista de nodos
for (InetAddress ia : peers) {
if (ia.equals(ip)) return;
}
peers.add(ip);
} catch (Exception e) {
peers.remove(ip);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment