Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By Chris2016
#38293 Dear all, I seem to be having difficulties with the WiFiServer class. MWE:
Code: Select allWiFiServer tcpTelnetServer(23);
WiFiClient tcpTelnetClient; // Only one client at a time a.t.m.!

void setup() {
  tcpTelnetServer.begin();
}

void loop() {
  // HANDLE TCP TELNET SERVER
  if (!tcpTelnetClient.connected()) {
    tcpTelnetClient = tcpTelnetServer.available();
    if (tcpTelnetClient.connected()) {
      tcpTelnetClient.setNoDelay(true);
      Serial.println(" DBG: New TCP client connected...");
    }
  } else {
    // remember: Telnet sends \r or \r\n, NOT \n!
    if (tcpTelnetClient.available()) {
      char stringBuffer[300];
      tcpTelnetClient.readBytesUntil('\r', stringBuffer, sizeof(stringBuffer)-1); // Fill buffer to max-1
      tcpTelnetClient.flush();
      // Process command...
      for (int i=0; i<6; i++) {
        memset(stringBuffer, 't', 60);
        stringBuffer[60] = 0; // Zeroterminate manually!
        Serial.printf("Before (%d): %d\n", i, micros());
        tcpTelnetClient.print(stringBuffer);
        Serial.printf("Middle (%d): %d\n", i, micros());
        tcpTelnetClient.write((uint8_t *)stringBuffer, strlen(stringBuffer)); // Force it to pick the right function!
        Serial.printf("After  (%d): %d\n\n", i, micros());
      }
    }
  }
}


It yields:
Code: Select allBefore (0): 46582971
Middle (0): 46785297
After  (0): 46984893

Before (1): 46985136
Middle (1): 47393106
After  (1): 47803031

Before (2): 47803275
Middle (2): 48212294
After  (2): 48621882

Before (3): 48622126
Middle (3): 48827013
After  (3): 49236314

Before (4): 49236558
Middle (4): 49647626
After  (4): 49854952

Before (5): 49855141
Middle (5): 50054827
After  (5): 50254701


200ms for one meager write?!?!? The write calls block. I tried setting "setnodelay(true)", to no avail. Is this a bug? Am I doing something wrong? The Server example (not the *WEB* server example) is a bit unclear on how a tcp-connection is to be treated, handled, managed, etc...
User avatar
By Chris2016
#38402 Well, I tested a bit, and found while it's working basically, it's still not acceptable b/c the buffer needs to be filled first and I cannot create a "true" streaming server for a responsive interactive shell on the ESP. So, until this extended, I'm sticking with UDP for the time being.
User avatar
By Chris2016
#38494 I'll collect some links worth reading in this post:
  • http://bbs.espressif.com/viewtopic.php?t=216 They unfortunately did not reach a conclusion, but a user named "tve" confirmed the bug and stated that it has nothing to do with the hardware or the hardware driver since pings and TCP resets to non-open ports are possible in 20ms. In my own setup pings are possible in 2-5ms. So it must be a bug in expressif's binary library (according to the source).