mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Ethernet: partially fix flush() behaviour in EthernetUDP
We still need to check if trasmission is completed, BTW this commit should alleviate bugs involving data loss. See #4029
This commit is contained in:
parent
4878d5c2ec
commit
b7173ed06c
@ -118,7 +118,12 @@ size_t EthernetUDP::write(const uint8_t *buffer, size_t size)
|
||||
int EthernetUDP::parsePacket()
|
||||
{
|
||||
// discard any remaining bytes in the last packet
|
||||
flush();
|
||||
while (_remaining) {
|
||||
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
|
||||
// should only occur if recv fails after telling us the data is there, lets
|
||||
// hope the w5100 always behaves :)
|
||||
read();
|
||||
}
|
||||
|
||||
if (recvAvailable(_sock) > 0)
|
||||
{
|
||||
@ -206,14 +211,7 @@ int EthernetUDP::peek()
|
||||
|
||||
void EthernetUDP::flush()
|
||||
{
|
||||
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
|
||||
// should only occur if recv fails after telling us the data is there, lets
|
||||
// hope the w5100 always behaves :)
|
||||
|
||||
while (_remaining)
|
||||
{
|
||||
read();
|
||||
}
|
||||
// TODO: we should wait for TX buffer to be emptied
|
||||
}
|
||||
|
||||
/* Start EthernetUDP socket, listening at local port PORT */
|
||||
|
Loading…
x
Reference in New Issue
Block a user