Client multipli WiFi

Ciao a tutti e grazie fin d'ora per il supporto.

Vi spiego il mio problema:
io ho un Arduino 2009 con WiFi shield; Se faccio girare lo skatch webserver tutto ok (chrome fa la richiesta e arduino risponde tutte le volte che voglio).
Se faccio girare lo skarch webclient altrettanto bene (apro telnet sul pc e arduino ci comunica tutte le volte che voglio).

Il problemone sorge quando cerco di unire le cose. In breve io sono in attesa di una connessione sulla 80 tcp, appena mi arriva, rispondo, e la chiudo.
Poi ne apro una nuova sulla 9100, mando dati e funziona.

Quando però dovrebbe ripartire il loop non mi funziona più la

WiFiClient client = server.available(); // listen for incoming clients

// delay(1000);
if (client) { // if you get a client,
//client.flush();
Serial.println("new client"); // print a message out the serial port
// String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
// ChiSono = client;
if (client.available()) {
...............

Qualcuno di voi sa dirmi il perché?!?!?!?

Sotto ho messo tutto il codice x verifica...

Grazie Grazie Grazie!
:slight_smile:
Ian

void loop() {
//client.stop();
//clKUBE.stop();
String CosaMandare = "";
Serial.print("ATTENDO: ");
//Serial.println(server.available());
WiFiClient client = server.available(); // listen for incoming clients

delay(1000);
if (client) { // if you get a client,
//client.flush();
Serial.println("new client"); // print a message out the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected

if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
if (c == '\n') { // if the byte is a newline character

// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();

// the content of the HTTP response follows the header:
//client.print("<a href="/H">ACCENDI
");
//client.print("<a href="/L">SPEGNI
");
client.println("OK");
// The HTTP response ends with another blank line:
client.println();
Serial.println("MANDOINDIETRO");
break;
////////////////////////////////////////////

//Serial.println("SISISI");
//Serial.println("2");

}
else { // if you got a newline, then clear currentLine:
currentLine = "";
}
}
else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
//Serial.println(currentLine);
// Check to see if the client request was "GET /H" or "GET /L":

if (currentLine.endsWith("IG-END")) {
//Ho ricevuto un comando di stampa...

CosaMandare = currentLine;

//Adesso devo leggere l'ultimo pezzo...
//Serial.println(TestoDaPrint.substring(da,i));
//da=i+1;
//Serial.println(TestoDaPrint);
}
}
}
// close the connection:
//clKUBE.stop();
client.stop();
while(client.connected());
if (CosaMandare != "") {
Serial.println(CosaMandare);
if (clKUBE.connect(kube, 9100)) {
Serial.println("CONNESSO KUBE");
// Make a HTTP request:
clKUBE.stop();
while(clKUBE.connected());
Serial.println("FINE KUBE");
}
}

}
else {

}
//Serial.println(WiFi.localIP());
}
}