File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
arduino/libraries/WiFi/src Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ int WiFiClient::available()
105
105
106
106
int result = 0 ;
107
107
108
+ // This function returns the number of bytes of pending data already received in the socket’s network.
108
109
if (lwip_ioctl_r (_socket, FIONREAD, &result) < 0 ) {
109
110
lwip_close_r (_socket);
110
111
_socket = -1 ;
@@ -150,6 +151,7 @@ int WiFiClient::peek()
150
151
{
151
152
uint8_t b;
152
153
154
+ // This function tries to receive data from the network and can return an error if the connection when down.
153
155
if (lwip_recv_r (_socket, &b, sizeof (b), MSG_PEEK | MSG_DONTWAIT) <= 0 ) {
154
156
if (errno != EWOULDBLOCK) {
155
157
lwip_close_r (_socket);
@@ -177,7 +179,10 @@ void WiFiClient::stop()
177
179
uint8_t WiFiClient::connected ()
178
180
{
179
181
if (_socket != -1 ) {
180
- peek ();
182
+ // Check if there are already available data and, if not, try to read new ones from the network.
183
+ if (!available ()) {
184
+ peek ();
185
+ }
181
186
}
182
187
183
188
return (_socket != -1 );
You can’t perform that action at this time.
0 commit comments