Rick,
We’re going down the same path, more or less. One thing to watch on
tcp_close is the tcb_pcb isn’t actually finished being used until
later – one of the tcp timers is completing the connection. This ties
up pcbs internally for older connections until they are closed.
Allocate MEMP_NUM_TCP_PCB to twice what you think – or more if you are
opening and closing connections a lot.
One thing I would like to see is a callback when the pcb is going to
be deallocated so that dynamic memory associated with it can be
released when the data is sent and the connection completes later.
Maybe someone knows already how to do this?
Thanks,
Bill Auerbach
------------------------------------------------------------------------
*From:* address@hidden
[mailto:address@hidden *On
Behalf Of *Rick Culver
*Sent:* Wednesday, January 09, 2008 12:29 PM
*To:* address@hidden
*Subject:* [lwip-users] Releasing pcb after tcp_new()
I am using CALLBACK API and set up a pcb using tcp_new() followed by
tcp_bind() followed by tcp_listen() & tcp_accept(). In my accept() for
a valid connection I use tcp_close() to close the LISTEN connection to
avoid any additional connection requests for a new connection. When I
am done using the connection I use tcp_close() to shut it down and
then repeat the process with tcp_new() to start a new LISTEN port. My
problem is 2 fold.
First I find that the 2nd time through the tcp_bind() function I get
an ERR_USE return which appears to be caused by the active list of pcb
still having the old port number in it. I think ther is a problem with
tcp_bind() which causes this to happen.
Secondly (and the biggest problem) is that once I get the ERR_USE then
I have a pcb allocated and this consumes pcb space and I eventually
run out of space. So the question is, if I get an error with
tcp_bind() how can I release the pcb allocated by the tcp_new() so I
do not consume pcb memory space and fill it up. I think there could be
a problem with tcp_bind() giving this error which is also an issue.
Can anyone suggest how to approach these problems?
Rick
------------------------------------------------------------------------
_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users