Documentation says that tcp_close will free pcb structure
(eventually). All of the callbacks that are used for tcp server are
registered with this structure.
But when client sends new packet and starts a new connection, accept
callback is called! Even though tcp_accept(echo_pcb, echo_accept);
(i.e. callback registration) is done only once in the init function
and that echo_pcb structure is already freed after tcp_close.
So I'm confused. I thought callback registration is done on a pcb basis,
i.e. function pointer is copied into pcb. So when pcb is freed all
callbacks should be registered again for a new pcb.
Re: Raw TCP API: question about tcp_close and accept callback in
A TCP server might handle many incoming connection requests, each one of
them will fire the accept callback.
That callback is responsible for acquiring any memory that it would need
for the application, and then will register callbacks for that instance
of the application. There is one instance per connection.
When the connection is closed, memory is freed and callbacks unregistered.
There is one accept callback per port, you listen on a port, which uses
a listening pcb (your calls to tcp_new() and tcp_bind() at init, your
There is one set of callbacks per connection, each connection uses a new
pcb (your 'tpcb'), the listening pcb is always listening for other new