提交 88293a42 编写于 作者: M me-no-dev

Implement WiFiClient.peek()

Thanks @miomir1981
上级 06a76eeb
......@@ -237,6 +237,20 @@ int WiFiClient::read(uint8_t *buf, size_t size)
return res;
}
int WiFiClient::peek()
{
if(!available()) {
return -1;
}
uint8_t data = 0;
int res = recv(fd(), &data, 1, MSG_PEEK);
if(res < 0 && errno != EWOULDBLOCK) {
log_e("%d", errno);
stop();
}
return data;
}
int WiFiClient::available()
{
if(!_connected) {
......
......@@ -47,10 +47,7 @@ public:
int available();
int read();
int read(uint8_t *buf, size_t size);
int peek()
{
return -1;
}
int peek();
void flush();
void stop();
uint8_t connected();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册