File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ extern "C" {
30
30
#include " WiFiServer.h"
31
31
32
32
WiFiServer::WiFiServer (uint16_t port) :
33
- _sock(NO_SOCKET_AVAIL)
33
+ _sock(NO_SOCKET_AVAIL),
34
+ _lastSock(NO_SOCKET_AVAIL)
34
35
{
35
36
_port = port;
36
37
}
@@ -49,7 +50,19 @@ WiFiClient WiFiServer::available(byte* status)
49
50
int sock = NO_SOCKET_AVAIL;
50
51
51
52
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
+ }
53
66
}
54
67
55
68
if (sock != NO_SOCKET_AVAIL) {
@@ -59,6 +72,8 @@ WiFiClient WiFiServer::available(byte* status)
59
72
*status = client.status ();
60
73
}
61
74
75
+ _lastSock = sock;
76
+
62
77
return client;
63
78
}
64
79
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ class WiFiClient;
32
32
class WiFiServer : public Server {
33
33
private:
34
34
uint8_t _sock;
35
+ uint8_t _lastSock;
35
36
uint16_t _port;
36
37
void * pcb;
37
38
public:
You can’t perform that action at this time.
0 commit comments