I am trying to send and receive data with the TCP server but I am not receiving data.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
// Parametros de conexion a red WIFI.
const char* ssid = "bits";
const char* password = "12345";
// Start a TCP Server on port 5000
WiFiServer server(5000);
void setup() {
Serial.begin(115200);
WiFi.begin(ssid,password);
Serial.println("");
//Wait for connection
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(WiFi.localIP()); // IP
// Start the TCP server
server.begin();
}
void loop() {
TCPServer();
}
void TCPServer () {
WiFiClient client = server.available();
if (client) {
Serial.println("We have a new client");
Serial.println("Hello, client!");
if (client.available() > 0) {
char thisChar = client.read();
Serial.println("We got data");
Serial.println(thisChar);
delay(200);
}
}
}
Test Capture: In the capture it is seen that the code is executed until the following instruction.
Serial.println("We have a new client");
Serial.println("Hello, client!");