You need to read about the layer model to understand where you play
first google hit: β https://www.ad-net.com.tw/osi-model-tcp-ip-network-models-must-concept-understand-move-deeper-networking-adventures/
As you can see in their table, the TCP/IP model offers multiple layers

So where you want to play is not the Application layer, but at the transport layer, in the world of TCP and UDP.
The web is full of articles explaining the difference, here are a couple ones from a google hit: β TCP vs UDP: Key Difference Between Them and TCP vs. UDP: Whatβs the Difference? - Lifesize (many more to read)
So if you want to focus on TCP (connection-oriented versus the connectionless UDP), you need to be able to
- establish the connection (ie identify who you are going to talk to)
- discuss over the connection (both ways)
- terminate the connection
So the question becomes how do you identify who you are going to talk to.
You are discussing with an application (or a service). TCP has something known as a port which is a unique number assigned to different applications. Standard services (applications) have well known ports that are documented
- HTTP β 80
- HTTPS β 443
- FTP β 21
- FTPS / SSH β 22
- POP3 β 110
- POP3 SSL β 995
- IMAPβ 143
- IMAP SSL β 993
- SMTP β 25 (Alternate: 26)
- SMTP SSL β 587
- MySQL β 3306
- cPanel β 2082
- cPanel SSL β 2083
- WHM (Webhost Manager) β 2086
- WHM (Webhost Manager) SSL β 2087
- Webmail β 2095
- Webmail SSLβ 2096
- WebDAV/WebDiskβ 2077
- WebDAV/WebDisk SSL β 2078
- ...
so you need to know what PORT is used by the remote service you are trying to reach out to. You can create a service on the port you want, best is of course to stay out of well know ports if you want to offer a new service.
Then you need to know where is that service being provided from. That's where you need to read about the layer below. You will need an IP address (from the network Layer).
Once you have gathered the target IP and port number, you are all set. What you send/receive over that link is custom and depends on the application and usually there is a formally documented protocol to manage the conversation.
For example, HTTP is an extensible application layer protocol that you use over TCP* but as you have seen from the list of ports, there are many more frequently used services that have they own specification and of course you can build your own
The Arduino library offers the WiFi library to abstract that in the Client class. (there are also capabilities to support UDP)
Here are the methods you can use:
Client class
The client class creates clients that can connect to servers and send and receive data.
Assume you successfuly connected to the network then you can do
IPAddress remoteHost(xxx,xxx,xxx,xxx); // IP address of the remote service
uint16_t portNumber = 21; // FTP standard port number
WiFiClient client;
if (client.connect(remoteHost, portNumber)) {
// here you are connected, you can use the documented FTP protocol to discuss with the service
}
The next question might be, "Ok, I need to know the IP, port and protocol of the service I want to reach out to in order to have something useful, but how do I create the service ?"
that's where the Server class is useful. It offers many methods too
Server class
The Server class creates servers which can send data to and receive data from connected clients (programs running on other computers or devices).
so you create a server on one of your ESP specifying the port you want to listen to (a uint16_t number) and use begin() to start the service.
uint16_t portNumber = 21; // FTP standard port number
WiFiServer ftpService(portNumber);
...
void setup() {
...
ftpService.begin(); // starts the service that will listen on port portNumber
...
makes sense? hopes it helps you get started.
have fun.
*footnote: HTTP can actually be sent over a TLS-encrypted TCP connection or theoretically any reliable transport protocol