It's a bit wasteful, but could he pre-allocate what tcp_write would do when copy is enabled, if it passes, free the memory and then call tcp_write. If the pre-allocate fails, it would have in tcp_write also.
Is there a way to allocate a pbuf with a mem_malloced payload that the stack knows to mem_free when it's done? If so, he could mem_malloc and copy himself and let the stack free it up. Bill >-----Original Message----- >From: [email protected] >[mailto:[email protected]] On >Behalf Of Simon Goldschmidt >Sent: Monday, November 09, 2009 1:35 AM >To: Chris Strahm; Mailing list for lwIP users >Subject: Re: [lwip-users] TCP_WRITE [Raw] > > >> In other words, could memory still be required for data copy that is >not >> checked by the tcp sndbuf queue space. > >Yes. That's because tcp_sndbuf() tests against a counter variable that >can be configured to any size in lwipopts.h. However, the memory needed >to enqueue a segment can be configured in lwipopts.h, too. If these >values don't match, tcp_write() can return ERR_MEM although the sndbuf >limit isn't reached yet. > >> If so, is there a check to test for available mem to copy data? > >That's hard: depending on whether you copy data or not, you need a >PBUF_RAM or PBUF_ROM pbuf. In addition to that, you need one struct >tcp_seg. These come from the corresponding memp pools, but there is no >default way (aside from looking at the stats, maybe) to know if >tcp_write will fail or not. > >However, this is just the way lwIP is designed: your application code >just has to cope with tcp_write failing, that's all :-) > >Simon >-- >GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! >Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 > > >_______________________________________________ >lwip-users mailing list >[email protected] >http://lists.nongnu.org/mailman/listinfo/lwip-users _______________________________________________ lwip-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
