[En-Nut-Discussion] Failed HTTP request

Harald Kipp harald.kipp at egnite.de
Thu Apr 21 10:04:50 CEST 2011


Hi Ulrich,

On 4/20/2011 9:15 PM, Ulrich Prinz wrote:

> You get the text through TCP, so the text is in the TCP buffer. Is there
> a chance to just pass the pointer to the beginning of the text to the
> function decoding it instead of copying it over?

Avoiding TCP buffer copying has been discussed for many years for all 
operating systems. The main problem is, that a lot of software exists 
for the BSD socket API and programmers are familiar with this interface. 
Any attempt to implement a zero-copy interface will more or less result 
in an incompatible interface.

Larger operating system with MMU support face an additional problem, 
because DMA buffers need to be allocated as locked, physical memory. 
Several proposals exist, a few of them had been implemented, none of 
them had been established as an accepted standard yet.


> I know, it's not that easy as I state it above, as there might more
> packets coming in and the TCP buffer is required to receive them. But if
> you could spare the text buffer you may add another TCP buffer and can
> keep one of them marked busy for a longer time than the others.

No, it's not trivial. Beside this, it must provide an API, that will be 
easily accepted by programmers. Not to mention the effort it would take 
to provide the documentation. The BSD socket interface is well 
understood and documented. Also note, that Nut/OS allows to use stdio 
functions on TCP sockets, which makes it easy to use and most flexible.

Something could be done, though. The main issue is the implementation of 
fgets(), which repeatedly calls fgetc(). IMHO, this is a good starting 
point and will be for the benefit of other interfaces, e.g. UART.


> The idea is stolen from the ARM/Cortex TCP system, where you simply mark
> which buffer is used by whom and buffers not marked free are not filled
> by the EMAC.

The idea is not new. I'm not familiar with this stack, but other 
implementations use this method together with an asynchronous interface, 
calling, for example, a registered callback function as soon as data is 
available. Does this stack provide a stdio interface?

Regards,

Harald




More information about the En-Nut-Discussion mailing list