Created
March 28, 2018 09:28
-
-
Save josemmo/08fa9939f2178986cfc9b71039196368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void propagate(Object message) { | |
new Thread(() -> { | |
for (InetAddress ip : peers) { | |
// Abrir socket hacia el nodo | |
Socket s = new Socket(); | |
s.connect( | |
new InetSocketAddress(ip, Cutrecoin.PORT), | |
Cutrecoin.TIMEOUT); | |
ObjectOutputStream outputStream = | |
new ObjectOutputStream(s.getOutputStream()); | |
ObjectInputStream inputStream = | |
new ObjectInputStream(s.getInputStream()); | |
// Enviar mensaje | |
send(outputStream, message); | |
// Esperar una posible respuesta | |
Object response = inputStream.readObject(); | |
onNewMessage(outputStream, response); | |
// Cerrar socket | |
s.close(); | |
} | |
}).start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment