Help to understand a bit of a code! (ESP8266)

I am learning this esp8266 now, and i saw this code was used in a tutorial for turning on and off a led using wifi, but can someone explain to me how this works?

String req = client.readStringUntil('\r'); // what does client.readStringUntil do?
Serial.println(req);
client.flush(); // what does client.flush do?
if (req.indexOf("/off") != -1) // what does the !=-1?

Hope someone can help me :slight_smile:

RTFM:
ReadStringUntil
Flush
IndexOf

Pieter

Thanks for the help. I will take a look now :slight_smile: But what does the !=-1 do?

It's in the link I posted. indexOf returns -1 if the substring is not found.

(deleted)

(deleted)

kjetilmarstein:
client.flush(); // what does client.flush do?

here nothing. there was mistake in some Arduino libraries where flush() cleaned the input, but it should send the buffered output