TCP Server Listener
The below Arduino code will also create a server and Access Point in ESP8266 which will continuously listen for a connection.
Code
//www.ArunEworld.com #include <ESP8266WiFi.h> #include <WiFiClient.h> #include <ESP8266WebServer.h> const char *ssid = "ArunEworld"; const char *password = "Arun"; ESP8266WebServer server(80); void handleRoot() { server.send(200, "text/html", "<t1>ArunEworld</t1>"); server.send(200, "text/html", "<h1>ArunEworld : TCP WebServer Listener</h1>"); server.send(200, "text/html", "<h2>You are connected</h2>"); } void setup() { delay(1000); Serial.begin(115200); Serial.println(); Serial.print("Configuring access point..."); WiFi.softAP(ssid, password); IPAddress myIP = WiFi.softAPIP(); Serial.print("AP IP address: "); Serial.println(myIP); server.on("/", handleRoot); server.begin(); Serial.println("HTTP server started"); } void loop() { server.handleClient(); }
After uploading this sketch, you can find a new Access Point named “test” from your Laptop or PC.
Result