So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By shiningthing
#91522 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
User avatar
By shiningthing
#91530
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);
  }