Esp8266 TCP socket server and serial port

Hi, I am use a esp8266 and I am trying to get a simple TCP socket server, so that the client that connects can send and receive data using the serial port of the eps6266.

With this code I have managed to get the client to connect to the server and I can send data to the server and output it through the serial port, but how can I send data from serial port to client?

#include <ESP8266WiFi.h>

const char* ssid = "<>";
const char* password = "<>";

int LED_TCP = 2; // GPIO2 of ESP8266

WiFiServer wifiServer(80);

void setup() {

  Serial.begin(115200);
  delay(1000);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting..");
  }

  Serial.print("Connected to WiFi. IP:");
  Serial.println(WiFi.localIP());

  wifiServer.begin();
}

void loop() {
  WiFiClient client = wifiServer.available();
  if (client) {
    while (client.connected()) {
      while (client.available() > 0) {
        char c = client.read();
        Serial.write(c);
        delay(10);
      }
    }
    client.stop();
  }
}

have a look at serial port input

have a look at serial port input

it’s not what i need, with my code I can receive through the serial port the data sent by the client , now I need to send data to the client by entering it through the serial port, I am using this code but the client does not receive anything

#include <ESP8266WiFi.h>
const char* ssid = "<>";
const char* password = "<>";
int LED_TCP = 2; // GPIO2 of ESP8266
WiFiServer wifiServer(5045);

void setup() {
  Serial.begin(115200);
  delay(1000);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting..");
  }
  Serial.print("Connected to WiFi. IP:");
  Serial.println(WiFi.localIP());
  wifiServer.begin();
}

void loop() {
  WiFiClient client = wifiServer.available();
  if (client) {
    while (client.connected()) {
      while (client.available() > 0) {
        char c = client.read();
        Serial.write(c);
        delay(10);

        if (Serial.available()) {
          size_t len = Serial.available();
          uint8_t sbuf[len];
          Serial.readBytes(sbuf, len);
          client.write(sbuf, len);
          delay(1);
        }
      }
    }
  }
  client.stop();
}

your if(Serial.available()) is inside the control block of while (client.available() > 0) { - try seperating the ifs

void loop() {
  WiFiClient client = wifiServer.available();
  if (client) {
    while (client.connected()) {
      while (client.available() > 0) {
        char c = client.read();
        Serial.write(c);
        delay(10);
      }

        if (Serial.available()) {
          size_t len = Serial.available();
          uint8_t sbuf[len];
          Serial.readBytes(sbuf, len);
          client.write(sbuf, len);
          delay(1);
        }
    }
  }
  client.stop();
}