cancel
Showing results for 
Search instead for 
Did you mean: 

handling multiple TCP segments

programmer131
Associate II
Posted on October 27, 2016 at 10:27

hello!

I'm using STM32f407 discovery kit along with extension board for my webserver project, I've tested lwip demo code and it works fine. Problem comes when client sends a bigger packet, for example 2000 bytes, and server receives data in segmented form, is there a way to handle multiple segments in httpd.c file? may combine two segments to make it single before processing?

Thank you.

#stm32f4 #lwip #httpd
1 REPLY 1
Posted on October 27, 2016 at 12:53

http is built over tcp so what you receive is not a ''packet'', rather, a stream. But I understand your concern - tcp serves received data to http in chunks (I am reluctant to use ''packets'' here as the relationship to IP packets is indirect) indeed. In the recv callback (http_recv()), after whatever check you may have for data-completely-arrived determines you need to wait for more data, you either store the already received data into your own local storage (array in RAM); or (a more complex but potentially RAM-saving), use pbuf_cat() to chain up the received data, not pbuf_free() them until the last portion arrived, and when that happens, processing all of them (including pbuf_free()) at once. This requires to understand the pbuf mechanisms and have enough pbufs allocated.

There is

https://lists.nongnu.org/mailman/listinfo/lwip-users

aimed at lwip users, this sort of questions might be better answered there, as they are in fact not STM32 related.

JW