Home / References / ESP32 Library
Introduction to the ESP32 WiFiClient Library
The ESP32 WiFiClient Library allows the ESP32 microcontroller to connect to a remote server over a network using the TCP/IP protocol. This library enables your ESP32 to act as a client, establishing a connection with a server and sending/receiving data. It’s commonly used in IoT projects to interact with web services, cloud platforms, or other networked devices.
The WiFiClient library provides functions for managing connections, reading from and writing to a server, and handling communication errors. It is a crucial component for building networked applications with the ESP32.
For your convenience, we have categorized the ESP32 WiFiClient Library methods by functionality as follows:
Connection Management Category
These methods are used to establish, manage, and terminate network connections.
- connect – Initiates a connection to a specified IP address and port.
- stop – Closes the current connection.
- connected – Returns true if the client is connected, false otherwise.
Data Sending Category
These methods are used to send data to a connected server.
- print – Prints a string to the server.
- println – Prints a string followed by a newline to the server.
- write – Writes a single byte to the server.
Data Receiving Category
These methods are used to read data from a connected server.
- available – Returns the number of bytes available to read.
- read – Reads the next byte from the server, or -1 if none available.
- readBytes – Reads a specified number of bytes into a buffer, blocking until all are received.
- readString – Reads all available data as a String object.
- readStringUntil – Reads data into a String until a specified terminator character is encountered.
- peek – Returns the next byte without removing it from the buffer, or -1 if none available.
- flush – Discards any remaining data in the input buffer.
Configuration Category
These methods configure the client’s behavior or options.
- setSocketOption – set low-level socket options for the network connection
- setNoDelay – Enables or disables Nagle’s algorithm for immediate data sending.
Status and Information Category
These methods provide information about the connection or client state.
- remoteIP – Returns the IP address of the remote server.
- remotePort – Returns the port number of the remote server.
- localPort – Returns the local port number used by the client.
- getNoDelay – Returns whether Nagle’s algorithm is disabled.
ESP32 Library Index
- ESP32 WiFi Library
- ESP32 WiFiClient Library
- ESP32 HTTPClient Library
- ESP32 WiFiClientSecure Library
- ESP32 WebServer Library
- Which ESP32 Boards are Recommended for Learners
- How to Copy Codes from AvantMaker.com
- What is SPIFFS and how to upload files to it?
- What is LIttleFS and how to upload files to it?
Ready to experiment and explore more about ESP32? Visit our website’s All About ESP32 Resources Hub, packed with tutorials, guides, and tools to inspire your maker journey. Experiment, explore, and elevate your skills with everything you need to master this powerful microcontroller platform!