Wait for ACK before sending another TCP segment (esp8266)

I have a separate thread here on this forum in which I'm trying to serve a 1gig file reliably from a web server running on an esp8266.

My web server would be a lot more reliable if the server would wait for the previous TCP segment to be acknowledged before sending the next TCP segment. But in Wireshark you can see that it sends two PSH in a row without an ACK in between. The server's packets are in Yellow and the client's packets are in Red (so all the ACK's are in Red).

So does anyone know how I can check if the previous segment was acknowledged? So then I could do something like:

for ( unsigned i = 0u; i < count_segments; ++i )
{
    server.sendContent( data + (payload_size * i), payload_size );

    while ( false == server.AllPacketsACK() ) delay(30u);
}

I figured it out. You need to include the header files as follows:

#define protected public
#include <WiFiClient.h>
#undef protected
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include "lwip/tcp.h"
#include <../ESP8266WiFi/src/include/ClientContext.h>

and then write a function as follows:

void WaitUntilAllACK(ESP8266WebServer &server)
{
    WiFiClient &c = server.client();
    ClientContext &cc = *c._client;
    cc.wait_until_acked();
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.