 
     boolean newClient = true;
     for (byte i=0;i<4;i++) {
+      //check whether this client refers to the same socket as one of the existing instances:
       if (clients[i]==client) {
         newClient = false;
         break;

  }
  for (byte i=0;i<4;i++) {
    if (!(clients[i].connected())) {
      clients[i].stop();
      clients[i]=EthernetClient();
    }
  }
}

    }

    if (newClient) {
      //check which of the existing clients can be overridden:
      for (byte i=0;i<4;i++) {
        if (!clients[i] && clients[i]!=client) {
          clients[i] = client;
          break;
        }
