need close(sockfd) before sockfd = -1, "_connected = false and close socket" means stop() function. (#73)

This commit is contained in:
Hirotaka 2016-12-01 20:27:51 +09:00 committed by Me No Dev
parent 8904f52c39
commit 3c81739b33

View File

@ -166,8 +166,7 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
int res = send(sockfd, (void*)buf, size, MSG_DONTWAIT); int res = send(sockfd, (void*)buf, size, MSG_DONTWAIT);
if(res < 0) { if(res < 0) {
log_e("%d", errno); log_e("%d", errno);
_connected = false; stop();
sockfd = -1;
res = 0; res = 0;
} }
return res; return res;
@ -181,8 +180,7 @@ int WiFiClient::read(uint8_t *buf, size_t size)
int res = recv(sockfd, buf, size, MSG_DONTWAIT); int res = recv(sockfd, buf, size, MSG_DONTWAIT);
if(res < 0 && errno != EWOULDBLOCK) { if(res < 0 && errno != EWOULDBLOCK) {
log_e("%d", errno); log_e("%d", errno);
_connected = false; stop();
sockfd = -1;
} }
return res; return res;
} }
@ -196,8 +194,7 @@ int WiFiClient::available()
int res = ioctl(sockfd, FIONREAD, &count); int res = ioctl(sockfd, FIONREAD, &count);
if(res < 0) { if(res < 0) {
log_e("%d", errno); log_e("%d", errno);
_connected = false; stop();
sockfd = -1;
return 0; return 0;
} }
return count; return count;