提交 3c81739b 编写于 作者: H Hirotaka 提交者: Me No Dev

need close(sockfd) before sockfd = -1, "_connected = false and close socket"...

need close(sockfd) before sockfd = -1, "_connected = false and close socket" means stop() function. (#73)
上级 8904f52c
......@@ -166,8 +166,7 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
int res = send(sockfd, (void*)buf, size, MSG_DONTWAIT);
if(res < 0) {
log_e("%d", errno);
_connected = false;
sockfd = -1;
stop();
res = 0;
}
return res;
......@@ -181,8 +180,7 @@ int WiFiClient::read(uint8_t *buf, size_t size)
int res = recv(sockfd, buf, size, MSG_DONTWAIT);
if(res < 0 && errno != EWOULDBLOCK) {
log_e("%d", errno);
_connected = false;
sockfd = -1;
stop();
}
return res;
}
......@@ -196,8 +194,7 @@ int WiFiClient::available()
int res = ioctl(sockfd, FIONREAD, &count);
if(res < 0) {
log_e("%d", errno);
_connected = false;
sockfd = -1;
stop();
return 0;
}
return count;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册