Hello,
I am trying to fix a strange behavior I have with LWIP...
Quite possibly I am using the LWIP wrongly, but I am not sure. I took over the maintaining of a embedded project which includes LWIP, and unfortunately I have some problems with networking (and I now face a steep learning curve, as LWIP has been integrated by someone else, and I know not enough about networking...).
I updated from 1.3.2 (which was used before) to 2.0.2. This helped with one problem I had - but introduced another.
Our application offers one port for SCPI connections.
The aim is to only allow n open TCP connection at a time, and reject all further connection requests. This worked reasonably well in 1.3.2, but now fails in 2.0.2.
I set the maximum number "n" of TCP PCBs like this, e.g. 4:
#define MEMP_NUM_TCP_PCB 4
The problematic behavior is this:
The first n connections work fine (in this example 1 to 4), and can be used simultaneously (I leave all 4 connections open).
The n+1 connection itself works fine (5th connection in this example), HOWEVER: this n+1 connection terminates the very 1st connection (takes over the 1st PCB?).
Now, if I leave all previous connections open and make a n+1 connection (the 6th connection in this example) I hit an exception (the processor tries to access memory that does not exists and I hit the exception handler in the MCU).
I narrowed down the origin of the fatal exception in tcp_alloc() to the code following this comment:
/* zero out the whole pcb, so there is no need to initialize members to zero */
The problem at that point seems to be that a struct tcp_pcb_listen (that is still in use) is reused and overwritten as a struct tcp_pcb...
However, as I have written above, something else goes wrong before that, when the n+1 connection is made. (possibly in tcp_alloc(), when tcp_kill_prio(prio); is called?)