Page 1 of 1

lwip server stm32f767

Posted: Fri Aug 04, 2023 8:43 pm
by Vitaly_Parkhomenko
Hello everyone! I am trying to create tcp server using lwip library on stm32f767.
I want my server to support multiple connections simultaneously. Is there the best way to do this? Right now i am thinking about 1 static thread for netconn_listen() and new dynamic thread for every connection(after closing connetcion dynamic thread will be deleted).

Re: lwip server stm32f767

Posted: Fri Aug 04, 2023 9:16 pm
by Giovanni
Hi,

I don't have an example, if I remember well there were user projects in this forum, try a search.

In principle having a thread for each request would be ideal, you could have a pool of ready threads for servicing without having to create/exit continuously.

Giovanni

Re: lwip server stm32f767

Posted: Sat Aug 05, 2023 9:35 pm
by steved
Depends a bit on the expected nature of network comms.including the number of simultaneous connections needed, and what you need to do.

For example, I have a network task where multiple remote hosts may initiate a connection to my system, always on the same port number, and all connections needing the same handling. There is a maximum number of simultaneous connections allowed (generally 6-10). So I have a single handler, with a single listener socket passing incoming 'open connection' requests to a new socket, until the limit is reached (all pretty standard network stuff). Then use select() to identify sockets with activity.

For the rest, I find that 'socket per thread' falls out of the code structure, since I tend to have a thread (sometimes two) dedicated to each task.