Chat here about code rewrites, mods, etc... with respect to the github project https://github.com/esp8266/Arduino

Moderator: igrr

User avatar
By Lord Ivanhoe
#17254 Of course, here it goes.

first declare the number of clients you wish to deal with:
Code: Select all#define numOfClients 4
WiFiClient clients[numOfClients];


And then in your loop{}

Code: Select all   
for (int i = 0; i <numOfClients-1; i++)
   {
      if (clients[i]) {
         if (clients[i].status() == CLOSED) {
            clients[i].stop();
         }
         if (clients[i].available()) {

            //do what you want with this client's  incoming data here

            clients[i].flush();
         }

      }
      else {
         clients[i] = server.available();
      }
   }


And thats about it. It works like a charm. Altho server.print() is not implemented yet AFAIK, so you should just make your own. Basically just loop through all clients and if they are connected, do a clients[i].println("your message"). That should do the trick.

I hope this helps :)

Ivan