From 532bd88062045014f6f62fd17436f59233297822 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 15 Mar 2018 00:41:01 +0800 Subject: [PATCH] Avoid possible packet loss The connect to peer done by server will auto terminate if same peer from same port has connected already --- src/network/protocols/request_connection.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/network/protocols/request_connection.cpp b/src/network/protocols/request_connection.cpp index 65fcf964a..d6d12f028 100644 --- a/src/network/protocols/request_connection.cpp +++ b/src/network/protocols/request_connection.cpp @@ -113,7 +113,14 @@ void RequestConnection::asynchronousUpdate() // Direct socket always listens on server discovery port server_addr.setPort(NetworkConfig::get() ->getServerDiscoveryPort()); - STKHost::get()->sendRawPacket(message, server_addr); + // Avoid possible packet loss, the connect to peer done by + // server will auto terminate if same peer from same port + // has connected already + for (int i = 0; i < 5; i++) + { + STKHost::get()->sendRawPacket(message, server_addr); + StkTime::sleep(1); + } m_state = DONE; } else