From fa652467b4fb227d704a771b0de12e6d3e1dd48e Mon Sep 17 00:00:00 2001 From: Christian Hammacher Date: Fri, 17 Jun 2022 15:17:23 +0200 Subject: Last bug fix for W5500 Fixed same bug as in the WiFi/LwIP socket implementations --- src/Networking/W5500Ethernet/W5500Socket.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Networking/W5500Ethernet/W5500Socket.cpp b/src/Networking/W5500Ethernet/W5500Socket.cpp index 46901f2e..6e24850c 100644 --- a/src/Networking/W5500Ethernet/W5500Socket.cpp +++ b/src/Networking/W5500Ethernet/W5500Socket.cpp @@ -178,7 +178,15 @@ void W5500Socket::Poll() noexcept { MutexLocker lock(interface->interfaceMutex); - switch(getSn_SR(socketNum)) + uint8_t socketStatus = getSn_SR(socketNum); + if (socketStatus == SOCK_CLOSE_WAIT && state == SocketState::listening) + { + // We get here when only very little data had been transferred before the connection was closed again. + // In this case make sure a network responder has a chance to deal with the pending data + socketStatus = SOCK_ESTABLISHED; + } + + switch(socketStatus) { case SOCK_INIT: // Socket has been initialised but is not listening yet if (localPort != 0) // localPort for the FTP data socket is 0 until we have decided what port number to use -- cgit v1.2.3