ESP8266 esp-12 tcp server disconnect from client
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
-hi 4 all
I wrote a program that esp8266 work as a ap and i initialize a tcp server on it
When a client connect to it, the client disconnected immediatly from server
```cpp
#include
#include
#ifndef APSSID
#define APSSID "ESPap"
#define APPSK "thereisnospoon"
#endif
// Hardcode WiFi parameters as this isn't going to be moving around.
const char *ssid = APSSID;
const char *password = APPSK;
// Start a TCP Server on port 5045
WiFiServer server(5045);
WiFiClient client;
//boolean alreadyConnected=false;
void setup() {
delay(1000);
Serial.begin(9600);
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("IP Address: "); Serial.println(myIP);
// Start the TCP server
server.begin();
Serial.println("TCP server started");
}
void loop() {
// listen for incoming clients
client = server.available();
if (client){
// if (!alreadyConnected)
// {
// client.flush();
// Serial.println("We have a new client");
// client.println("Hello client");
// alreadyConnected=true;
// }
Serial.println("new client connected");
while (client.connected() || client.available()){
if (client.available())
{
// Read the incoming TCP command
char command = client.read();
// Debugging display command
Serial.print(command);
}
}
if (!client.connected())
{
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
}
}
```
i has wireshark capture of it

please hekp me
thanks
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.