-->
Page 1 of 1

Socket programming esp8266 client C# server

PostPosted: Sun Apr 02, 2017 2:29 pm
by silver boy
Hi
I,m working on project that reading RFID and send to C# server , but when the esp code finish and wants start over c# got error .

for now it just send a string and read string from server;
I am appreciate for help.
And here error
Image
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>

const char* ssid = "";
const char* pass = "";
const char* host = "";
     

int buttonState = 1;         

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.print("conecting to: ");
  Serial.println(ssid);
  Serial.println("Try to connect to server: ");
  Serial.println(host);

  delay(1000);
  WiFi.begin(ssid, pass);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }

  Serial.println();
  Serial.print("My IP: ");
  Serial.println(WiFi.localIP());
 

}

void loop() {
  WiFiClient client;
  Serial.print("Connecting to server");
  while (!client.connect(host, 8888)) {
    Serial.print(".");

    yield();
  }
  Serial.println();
  Serial.print("Conected to IP: ");
  Serial.println(host);

 

  Serial.println("Sending string to server: ");
 
  client.println("RFID");
  delay(1000);
  String line = client.readStringUntil('\n');
  Serial.print(line);

 

  Serial.println();
  Serial.println("Closing connection");
  client.flush();
  client.stop();
  Serial.println("Connection Closed");
  yield();
}


Re: Socket programming esp8266 client C# server

PostPosted: Mon Apr 03, 2017 9:36 am
by daniel_ezsbc
If you don't assign values to these strings
const char* ssid = "";
const char* pass = "";
const char* host = "";
nothing will work.