mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-12 18:26:30 +02:00
Implement WiFiClient.peek()
Thanks @miomir1981
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user