Kieran Mansley schrieb:
Each time tcp_sent is called it tells you how much data has been
released.  Keep a count of this.  When your count equals the size of
data you sent, you know it's all done.

This is the original http_sent:

static err_t http_sent(void *arg, struct tcp_pcb *pcb, u16_t len) {
  struct http_state *hs;

  LWIP_UNUSED_ARG(len);
  hs = arg;
  hs->retries = 0;

  if (hs->left > 0) {
    send_data(pcb, hs);
  } else {
    close_conn(pcb, hs);
  }
  return ERR_OK;
}

If hs->left == 0 this does not mean that all data has already been sent out. The last packet is just somewere in the pipeline. So the connection cannot be closed yet.

I can remember something puzzled my when doing the first steps: Used buffers where freed by a function called from the timers. Probably this was the cause.

I would suggest to add bytes_to_send and bytes_acked to struct http_state and to change the function like this:

static err_t http_sent(void *arg, struct tcp_pcb *pcb, u16_t len) {
  struct http_state *hs;

  LWIP_UNUSED_ARG(len);
  hs = arg;
  hs->retries = 0;
  hs->bytes_acked+=len;
        
  if (hs->left > 0) {
    send_data(pcb, hs);
  }
  if (hs->bytes_acked==hs->bytes_to_send) {
    close_conn(pcb, hs);
  }
  return ERR_OK;
}



_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to