ok, that's all quite a mistery for me.
I tried this test sketch in 4 versions:
/*
Web Server
*/
#include
#include
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(172, 18, 67, 96);
EthernetServer server(80);
#define VERSION 0 // 0 no, 1 reduced client print
// 0 12912/725 --> 122
// 1 12858/731 --> 71
// 2 12926/611 --> 387
// 3 13020/735 --> 19
void setup() {
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Ethernet WebServer Example");
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
// start the server
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
#if VERSION == 0
client.println("HTTP/1.0 200 OK"); // changed
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println();
client.println("");
client.println("");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(random(100, 1000));
client.println("
");
}
client.println("");
#elif VERSION == 1
client.print ("HTTP/1.0 200 OK\r\n" // changed 271/208
"Content-Type: text/html\r\n"
"Connection: close\r\n" // the connection will be closed after completion of the response
"\r\n"
"\r\n"
"\r\n");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(random(100, 1000));
client.println("
");
}
client.println("");
#elif VERSION == 2
client.print (F("HTTP/1.0 200 OK\r\n" // changed
"Content-Type: text/html\r\n"
"Connection: close\r\n" // the connection will be closed after completion of the response
"\r\n"
"\r\n"
"\r\n"));
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print(F("analog input "));
client.print(analogChannel);
client.print(F(" is "));
client.print(random(100, 1000));
client.println(F("
"));
}
client.println(F(""));
#elif VERSION == 3
char buffer[400];
memcpy(buffer, '\0', 400);
strcpy(buffer, "HTTP/1.0 200 OK\r\n" // changed
"Content-Type: text/html\r\n"
"Connection: close\r\n" // the connection will be closed after completion of the response
"\r\n"
"\r\n"
"\r\n");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
strcat(buffer, "analog input ");
char c[8];
itoa(analogChannel, c, 10);
strcat(buffer, c);
strcat(buffer, " is ");
itoa(random(100, 1000), c, 10);
strcat(buffer, c);
strcat(buffer, "
\r\n");
}
strcat(buffer, "\r\n");
client.print(buffer);
#endif
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
Version 0 - Single client prints from RAM --> 122

Version 1 - Less single client prints from RAM --> 71

Version 2 - Less single client prints with F-Makro --> 387

Version 3 - buffer - one client print --> 19

interesting so far.
// V Flash/Globals Incomming
// 0 12912/725 Single client prints from RAM 54 packets
// 1 12858/731 Less single client prints from RAM 43 packets
// 2 12926/611 Less single client prints with F-Makro 257 packets
// 3 13020/735 buffer - one client print 6 packets
Have to adopt my wireshark settings. But at least I know I have to re-learn a lot...



