-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Open
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
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#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
Metadata
Metadata
Assignees
Labels
No labels
