lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Probem sending large files using LwIP


From: Kieran Mansley
Subject: Re: [lwip-users] Probem sending large files using LwIP
Date: Mon, 16 Jul 2007 16:21:10 +0100

On Sat, 2007-07-14 at 19:24 +0200, Louis Filasky wrote:

>           
>           if(ERR_OK == tcp_write(pcb, cs->data, len, 0)) {
>           cs->data += len;
>           cs->left -= len;
>           }
>           else if(ERR_MEM == tcp_write(pcb, cs->data, len, 0)) {  
>           tcp_output(pcb);
>           }

It's not really an answer to your question, but you'd be better off
rephrasing that bit of code to look like this (i.e. only calling
tcp_write() once):

  int rc;
  rc = tcp_write(pcb, cs->data, len, 0));
  if (rc == 0) {
    cs->data += len;
    cs->left -= len;
  }
  else if(rc == ERR_MEM) {  
    tcp_output(pcb);
  }

I'd also consider calling tcp_output() more often; it may be that you
can send data earlier than you are (no data will be sent on the wire
till the output call is made).  There's also a chance that it will make
no difference (or due to the increased overhead make things worse!) but
that's why it's a separate call - you can experiment to find what works
well for your traffic pattern.  You should definitely have a call to
tcp_output() at the end of the send_data function in case your whole
message has fitted into the send buffer (i.e. you always got ERR_OK
returned by tcp_write()).  Without it the data will just sit in the send
buffer. e.g. something like this:

  if (cs->left == 0)
    tcp_output(pcb);

Kieran





reply via email to

[Prev in Thread] Current Thread [Next in Thread]