Implement WiFiClient.peek()
Thanks @miomir1981
This commit is contained in:
parent
06a76eebe8
commit
88293a4284
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user