• @Wilberforce the best bet would be to tweak Telnet to add flow control in the firmware itself?

    It should be very easy. Just make: https://github.com/espruino/Espruino/blob/master/libs/network/telnet/jswrap_telnet.c#L292

    Check jshHasEventSpaceForChars.

    Maybe lower the buffer size a bit to make it a bit more fine-grained, but something like:

      char buff[64];
      if (!jshHasEventSpaceForChars(sizeof(buff))) return false;
      int r = netRecv(net, ST_NORMAL, tnSrv.cliSock-1, buff, sizeof(buff));
      if (r > 0) {
        jshPushIOCharEvents(EV_TELNET, buff, (unsigned int)r);
      } else if (r < 0) {
        telnetRelease(net);
      }
    

    would probably be perfect, and then TCP/IP should handle all the flow control stuff itself.

About

Avatar for Gordon @Gordon started