Skip to content

Commit 3c81739

Browse files
hirotakasterme-no-dev
authored andcommitted
need close(sockfd) before sockfd = -1, "_connected = false and close socket" means stop() function. (#73)
1 parent 8904f52 commit 3c81739

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Diff for: libraries/WiFi/src/WiFiClient.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
166166
int res = send(sockfd, (void*)buf, size, MSG_DONTWAIT);
167167
if(res < 0) {
168168
log_e("%d", errno);
169-
_connected = false;
170-
sockfd = -1;
169+
stop();
171170
res = 0;
172171
}
173172
return res;
@@ -181,8 +180,7 @@ int WiFiClient::read(uint8_t *buf, size_t size)
181180
int res = recv(sockfd, buf, size, MSG_DONTWAIT);
182181
if(res < 0 && errno != EWOULDBLOCK) {
183182
log_e("%d", errno);
184-
_connected = false;
185-
sockfd = -1;
183+
stop();
186184
}
187185
return res;
188186
}
@@ -196,8 +194,7 @@ int WiFiClient::available()
196194
int res = ioctl(sockfd, FIONREAD, &count);
197195
if(res < 0) {
198196
log_e("%d", errno);
199-
_connected = false;
200-
sockfd = -1;
197+
stop();
201198
return 0;
202199
}
203200
return count;

0 commit comments

Comments
 (0)