EasyManua.ls Logo

Freenove ESP32-S3 - Page 93

Default Icon
142 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Any concerns? support@freenove.com
91
Chapter 6 TCP/IP
www.freenove.com
43
44
45
46
47
if (Serial.available() > 0) {
delay(20);
String line = Serial.readString();
client.print(line);
}
If the server is disconnected, turn off WiFi of ESP32-S3.
48
49
50
51
if (client.connected () == false) {
client.stop();
WiFi.disconnect();
}
Reference
Class Client
Every time when using Client, you need to include header file "WiFi.h."
connect(ip, port, timeout)/connect(*host, port, timeout): establish a TCP connection.
ip, *hostip address of target server
port: port number of target server
timeout: connection timeout
connected(): judge whether client is connecting. If return value is 1, then connect successfully; If return
value is 0, then fail to connect.
stop(): stop tcp connection
print(): send data to server connecting to client
available(): return to the number of bytes readable in receive buffer, if no, return to 0 or -1.
read(): read one byte of data in receive buffer
readString(): read string in receive buffer