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;
|
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()
|
int WiFiClient::available()
|
||||||
{
|
{
|
||||||
if(!_connected) {
|
if(!_connected) {
|
||||||
|
@ -47,10 +47,7 @@ public:
|
|||||||
int available();
|
int available();
|
||||||
int read();
|
int read();
|
||||||
int read(uint8_t *buf, size_t size);
|
int read(uint8_t *buf, size_t size);
|
||||||
int peek()
|
int peek();
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
void flush();
|
void flush();
|
||||||
void stop();
|
void stop();
|
||||||
uint8_t connected();
|
uint8_t connected();
|
||||||
|
Loading…
Reference in New Issue
Block a user