From 161a1e6dcfccb7ae64b92a685effd00a95fef38e Mon Sep 17 00:00:00 2001 From: Norbert Schulz Date: Wed, 20 Nov 2024 11:16:34 +0100 Subject: [PATCH] WifiClient: Avoid repetitive map lookups in winsock variant, --- lib/WiFiNative/src/WifiClientWinsock.inl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/WiFiNative/src/WifiClientWinsock.inl b/lib/WiFiNative/src/WifiClientWinsock.inl index 4a700d5b..8b406eb2 100644 --- a/lib/WiFiNative/src/WifiClientWinsock.inl +++ b/lib/WiFiNative/src/WifiClientWinsock.inl @@ -176,9 +176,11 @@ size_t WiFiClient::write(const uint8_t* buffer, size_t size) if ((0U < size) && (0U != connected())) { + SOCKET socket = gSockets[this]; + while ((0U < remaining) && (retries < SOCK_WRITE_RETRY)) { - int written = ::send(gSockets[this], reinterpret_cast(buffer), remaining, 0); + int written = ::send(socket, reinterpret_cast(buffer), remaining, 0); if (SOCKET_ERROR == written) { int lastError = WSAGetLastError(); @@ -225,7 +227,7 @@ int WiFiClient::read(uint8_t* buffer, size_t size) } else if (1 == selectRet) /* read signaled */ { - ssize_t result = ::recv(gSockets[this], reinterpret_cast(buffer), size, 0); + ssize_t result = ::recv(socket, reinterpret_cast(buffer), size, 0); if (-1 != result) { retval = result; /* Success! */