Go Down

Topic: Web-server : how to increase downloading speed? (Read 236 times) previous topic - next topic

Dmitron1036

I have a classic code:
Code: [Select]

EthernetClient client = server.available();  // try to get client
File webFile;

if(SD.exists(GetData)){
  webFile = SD.open(GetData);
}

while(webFile.available() && File_type == true) {
client.write(webFile.read()); // send web page to client
}
webFile.close();


The download speed is 4kB/s.
How can I increase it?
I guess I need to use some buffer fo reading and writing?

Dmitron1036

I guess I should use
stream.readBytes(buffer, length)
or stream.readBytesUntil(character, buffer, length)

Code: [Select]

while(webFile.available() && File_type == true) {
client.write(  webFile.readBytesUntil(character, buffer, length)  ); // send web page to client
}

PaulS

Quote
I guess I should use
Well, you could perform a test, instead of guessing. I don't need to guess to know that sending 512 byte TCP packets that contain one byte of payload is going to be orders of magnitude slower than sending 512 byte TCP packets that contain 64 bytes of payload.
The art of getting good answers lies in asking good questions.

derVernichter

You should have a look into the ethernet library. my tests with an older version revealed that the library sends 1b segments causing lots of overhead.

Go Up