Hi,
I am trying to make tcp Server on Nodemcu and send data as requested by the client.
When i uploaded the program and the Nodemcu runs fine, connects to router and Starts the server but the client says Coundn’t connect to Host.
The client I am using is an Android app called Simple Tcp socket Tester for testing purposes.Both Nodemcu and android device are connected to the same router
Don’t know what the issue is… Here i am attaching the Screenshots and Code of my project.
#include <ESP8266WiFi.h>
const char* ssid = "IoT4143"; // ssid
const char* password = "redminote4";// password
IPAddress ip(192, 168, 42, 143); //set static ip
IPAddress gateway(192, 168, 0, 1); //set getteway
IPAddress subnet(255, 255, 255, 0);//set subnet
WiFiServer server(8061);
void setup() {
Serial.begin(115200);
delay(10);
// Connection to wireless network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println(WiFi.localIP());
server.begin();
Serial.println("Server started");
}
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
}