If I do the following when using the standard Arduino Ethernet2 shield and associated library:-
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: application/octet-stream"));
client.println(F("Content-Length: 512"));
client.println(F("Connection: close"));
client.println();
every character of the header text seems to be send within it's own tcp packet. Which then need all the associated syn/ack stuff. The F() macro seems to pop out each char individually. It doesn't seem very efficient and produces floods of packets back and forth. So it saves RAM at the expense of packets/transmission time and wears out my wires. Is this correct?
Can I just ask, how do all the quoted strings work? There's no concatenation between them like a "+". Just returns. Is concatenation inferred by the compiler? Or is it just programmer's magic?
"Connection: close\n\n")); // including the additional empty line!
correct? I think that's two additional lines as it's messing up my transfers. Isn't a return automatically appended by println? It works for me with just one slash en.
"Connection: close\n\n")); // including the additional empty line!
correct? I think that's two additional lines as it's messing up my transfers. Isn't a return automatically appended by println? It works for me with just one slash en.
HTTP request headers should be terminated by an empty line. standard requires them for GET request too. and HTTP requires \r\n not only \n.
use your original code only put BuffredPrint over client. Install StreamLib from Library Manager