How ESP8266 send and receive data with Winsock
Posted:
Mon May 31, 2021 9:19 am
by shiningthing
I use Winsock in Visual Basic 6 which has ASCII string data. I want to send that data to ESP8266 with TCP/IP Protocol, also from ESP8266 to VB6. Is this possible? If so, how it works? I've tried using the http port but it still doesn't work. Thank you in advance
Re: How ESP8266 send and receive data with Winsock
Posted:
Tue Jun 01, 2021 12:31 am
by JurajA
it is a standard communication over a TCP/IP network
Re: How ESP8266 send and receive data with Winsock
Posted:
Tue Jun 01, 2021 3:58 am
by shiningthing
JurajA wrote:it is a standard communication over a TCP/IP network
I used this code but it didn't work. Is there something wrong with this code? If I want to pass the string to a modulator-demodulator, how do I do that?
Code: Select all#include <ESP8266WiFi.h>
const char* ssid = "xxx"; //SSID Access Point
const char* password = "123"; //Password Access Point
const char* host = "http://192.168.100.1";
//Client-ESP8266 IP Address
IPAddress IP(192,168,100,200);
IPAddress NETMASK(255,255,255,0);
IPAddress NETWORK(192,168,100,1);
IPAddress DNS(192,168,100,1);
void setup() {
Serial.begin(1200);
delay(100);
// Connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
WiFiClient client;
Serial.printf("\n[Connecting to %s ...", host);
if (client.connect(host, 80))
{
Serial.println("connected]");
Serial.println("[Sending a request]");
client.print(String("GET /") + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n" +
"\r\n"
);
Serial.println("[Response:]");
while (client.connected() || client.available())
{
if (client.available()){
String line = client.readStringUntil('\n');
Serial.println(line);
}
}
client.stop();
Serial.println("\n[Disconnected]");
}
else
{
Serial.println("connection failed!]");
client.stop();
}
delay(5000);
}
Re: How ESP8266 send and receive data with Winsock
Posted:
Fri Jun 04, 2021 12:45 am
by JurajA