@@ -330,32 +330,33 @@ void tcpServerClientUpdate(uint8_t index)
330
330
int spot;
331
331
332
332
// Determine if the client data structure is in use
333
- if (tcpServerClientConnected & (1 << index))
333
+ while (tcpServerClientConnected & (1 << index))
334
334
{
335
- // Data structure in use
335
+ // The client data structure is in use
336
336
// Check for a working TCP server client connection
337
337
clientConnected = tcpServerClient[index]->connected ();
338
338
dataSent = ((millis () - tcpServerTimer) < TCP_SERVER_CLIENT_DATA_TIMEOUT) ||
339
339
(tcpServerClientDataSent & (1 << index));
340
- if (clientConnected && dataSent)
340
+ if (( clientConnected && dataSent) == false )
341
341
{
342
- // Display this client connection
343
- if (PERIODIC_DISPLAY (PD_TCP_SERVER_DATA) && (!inMainMenu))
344
- {
345
- PERIODIC_CLEAR (PD_TCP_SERVER_DATA);
346
- systemPrintf (" %s client %d connected to %s\r\n " ,
347
- tcpServerName, index,
348
- tcpServerClientIpAddress[index].toString ().c_str ());
349
- }
342
+ // Broken connection, shutdown the TCP server client link
343
+ tcpServerStopClient (index);
344
+ break ;
350
345
}
351
346
352
- // Shutdown the TCP server client link
353
- else
354
- tcpServerStopClient (index);
347
+ // Periodically display this client connection
348
+ if (PERIODIC_DISPLAY (PD_TCP_SERVER_DATA) && (!inMainMenu))
349
+ {
350
+ PERIODIC_CLEAR (PD_TCP_SERVER_DATA);
351
+ systemPrintf (" %s client %d connected to %s\r\n " ,
352
+ tcpServerName, index,
353
+ tcpServerClientIpAddress[index].toString ().c_str ());
354
+ }
355
+ break ;
355
356
}
356
357
357
- // Determine if the client data structure is in use
358
- if (! (tcpServerClientConnected & (1 << index)))
358
+ // Determine if the client data structure is not in use
359
+ while ( (tcpServerClientConnected & (1 << index)) == 0 )
359
360
{
360
361
if (tcpServerClient[index] == nullptr )
361
362
tcpServerClient[index] = new NetworkClient;
@@ -429,6 +430,7 @@ void tcpServerClientUpdate(uint8_t index)
429
430
tcpServerClientConnected = tcpServerClientConnected | (1 << index);
430
431
tcpServerClientDataSent = tcpServerClientDataSent | (1 << index);
431
432
}
433
+ break ;
432
434
}
433
435
}
434
436
0 commit comments