lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: [lwip] tcp_write()


From: Adam Dunkels
Subject: [lwip-users] Re: [lwip] tcp_write()
Date: Wed, 08 Jan 2003 23:38:37 -0000

Hi!

On Tuesday 11 June 2002 02.00, you wrote:
> I have a chain of pbufs that I want to write out over TCP... From what I
> can see, if I want to avoid a data copy, I have to call tcp_write for
> every pbuf in the chain... This will generate a tcp segment for each
> pbuf (only 128 bytes I think).  Is this correct?
>
> // I want to do this:
> tcp_write(pcb, p, size, 0);
>
> // where size is the sum of the p->payload data fields for the entire
> chain.
>
> Can I do this?  or does the data have to be in a contiguous buffer when
> the 'copy' parameter is set to 0 (zero)??

It cannot be done because of the way the TCP output interface is designed. 
tcp_write() takes (as you say) a pointer to a block of memory as an argument 
and not a pbuf. 

It could be done by using a loop around the tcp_write() call like this:

for(q = p; q != NULL; q = q->next) {
   err = tcp_write(pcb, q->data, q->len, 0);
   if(err == ERR_MEM) {
      /* Handle error. */
   }
}

/adam
-- 
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]




reply via email to

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