File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ extern "C" {
3030#include " WiFiServer.h"
3131
3232WiFiServer::WiFiServer (uint16_t port) :
33- _sock(NO_SOCKET_AVAIL)
33+ _sock(NO_SOCKET_AVAIL),
34+ _lastSock(NO_SOCKET_AVAIL)
3435{
3536 _port = port;
3637}
@@ -49,7 +50,19 @@ WiFiClient WiFiServer::available(byte* status)
4950 int sock = NO_SOCKET_AVAIL;
5051
5152 if (_sock != NO_SOCKET_AVAIL) {
52- sock = ServerDrv::availServer (_sock);
53+ // check previous received client socket
54+ if (_lastSock != NO_SOCKET_AVAIL) {
55+ WiFiClient client (_lastSock);
56+
57+ if (client.connected () && client.available ()) {
58+ sock = _lastSock;
59+ }
60+ }
61+
62+ if (sock == NO_SOCKET_AVAIL) {
63+ // check for new client socket
64+ sock = ServerDrv::availServer (_sock);
65+ }
5366 }
5467
5568 if (sock != NO_SOCKET_AVAIL) {
@@ -59,6 +72,8 @@ WiFiClient WiFiServer::available(byte* status)
5972 *status = client.status ();
6073 }
6174
75+ _lastSock = sock;
76+
6277 return client;
6378 }
6479
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ class WiFiClient;
3232class WiFiServer : public Server {
3333private:
3434 uint8_t _sock;
35+ uint8_t _lastSock;
3536 uint16_t _port;
3637 void * pcb;
3738public:
You can’t perform that action at this time.
0 commit comments