@@ -243,6 +243,7 @@ void P2P::ListenerThread(int update_interval)
243243 std::string totalMessage = " " ;
244244 std::map<int , std::string> messageParts = std::map<int , std::string>();
245245 int maxSegments = 0 ;
246+ uint32_t noreceipt = 0 ; // A counter that increments each time tick there is no message
246247
247248 while (!stop_thread_1)
248249 {
@@ -263,6 +264,8 @@ void P2P::ListenerThread(int update_interval)
263264
264265 if (iResult > 0 ) {
265266
267+ noreceipt = 0 ;
268+
266269 // Get the IPV4 address:port pair of the received data. If it
267270 // matches the expected one, continue. If it does not, then
268271 // stop. If the current one is blank or has disconnected,
@@ -277,7 +280,7 @@ void P2P::ListenerThread(int update_interval)
277280 p2pConnections[fromIPString]->life = 0 ;
278281
279282 // If not currently connected, accept this connection.
280- if (( otherAddrStr == " " || otherAddrStr == " 0.0.0.0:0" ) && otherAddrStr != clientIPPort ){
283+ if (otherAddrStr == " " || otherAddrStr == " 0.0.0.0:0" ){
281284 if (WalletSettingValues::verbose >= 4 )
282285 console::WriteLine (" \n Conversation Started" , console::greenFGColor, " " );
283286
@@ -587,6 +590,17 @@ void P2P::ListenerThread(int update_interval)
587590
588591 }
589592 }
593+ else if (noreceipt >= 100 ){
594+ if (WalletSettingValues::verbose >= 4 && otherAddrStr != " " )
595+ console::WriteLine (" noreceipt timeout check" );
596+ messageStatus = idle;
597+ messageAttempt = 0 ;
598+ otherAddrStr = " " ;
599+ noreceipt = 0 ;
600+ }
601+ else {
602+ noreceipt++;
603+ }
590604#if WINDOWS
591605 else if (WSAGetLastError () != WSAETIMEDOUT && WalletSettingValues::verbose >= 5 ) {
592606 console::NetworkErrorPrint ();
@@ -1092,13 +1106,15 @@ void P2P::SenderThread()
10921106 console::NetworkErrorPrint ();
10931107 console::WriteLine (" !! No peers seem to be online. Please try again later. !!" , console::redFGColor, " " );
10941108 differentPeerAttempts = 0 ;
1109+ otherAddrStr = " " ;
10951110 reqDat = -1 ;
10961111 }
10971112 }
10981113 // Otherwise, this is the answerer, so stop trying to reply to the original asker.
10991114 else {
11001115 role = -1 ;
11011116 messageStatus = idle;
1117+ otherAddrStr = " " ;
11021118 if (WalletSettingValues::verbose >= 5 ){
11031119 console::NetworkErrorPrint ();
11041120 console::WriteLine (" Asking peer went offline." , console::redFGColor, " " );
0 commit comments