arduino-libraries / Ethernet

Ethernet Library for Arduino
http://arduino.cc/
258 stars 265 forks source link

library looses incoming packets #108

Open geetee24 opened 5 years ago

geetee24 commented 5 years ago

brand new arduino branded ethernet 2 with using your latest code.

my app functions as web server.

when client sends large file, web server gets client.available to false at times due to appears your library cant keep up with incoming http data.

is there a way to not lose packets?

SapientHetero commented 5 years ago

It is not unusual for client.available() to return false and this does not indicate the loss of packets.

Your server should wait for client.available() != 0 and implement a timeout so it doesn't hang if the client has stopped sending. For example:

int start = millis(); while (!client.available()) { if (millis() - start > timeout_ms) break; } ... TCP/IP includes a metering mechanism (window size) to prevent buffer overruns; this is handled by the Wiznet Ethernet chips and not the library.

Hope that helps.

geetee24 commented 5 years ago

it does exactly that is is losing chars

On Mon, Aug 12, 2019 at 9:10 AM Sapient Hetero notifications@github.com wrote:

It is not unusual for client.available() to return false and this does not indicate the loss of packets.

Your server should wait for client.available() != 0 and implement a timeout so it doesn't hang if the client has stopped sending. For example:

int start = millis(); while (!client.available()) { if (millis() - start > timeout_ms) break; } ... TCP/IP includes a metering mechanism (window size) to prevent buffer overruns; this is handled by the Wiznet Ethernet chips and not the library.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arduino-libraries/Ethernet/issues/108?email_source=notifications&email_token=ABS6UT3SQJMVWEIFINRCPO3QEGDQHA5CNFSM4IK4GGQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4DA47I#issuecomment-520490621, or mute the thread https://github.com/notifications/unsubscribe-auth/ABS6UTYZF6IDE4JD3RHL5U3QEGDQHANCNFSM4IK4GGQQ .

SapientHetero commented 5 years ago

I don't doubt that your server is losing data; just noting that client.available() == 0 isn't an indication of lost packets.

It would be easier to help if you posted what hardware you're running on and the relevant portions of your code.