Hi, I am use a esp8266 and I have this portion of code from a tcp server that allows me to detect that a client has connected, but now I need to detect when a client has disconnected from the server, how can I do that, that I have to increase the code?
void loop(){
uint8_t i;
if (server.hasClient()){ //check if there are any new clients
for(i = 0; i < MAXCLIENTS; i++){
if (!serverClients[i] || !serverClients[i].connected()){ //find free/disconnected spot
if(serverClients[i])
serverClients[i].stop();
serverClients[i] = server.available();
//Serial.print("New client: "); Serial.print(i);
continue;
}
}
//no free/disconnected spot so reject
WiFiClient serverClient = server.available();
serverClient.stop();
//Serial.println("No client slot available");
}