[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Raw TCP API: question about tcp_close and accept callback i
[lwip-users] Raw TCP API: question about tcp_close and accept callback in
Sat, 29 Sep 2018 15:44:16 +0300
I'm looking at "TCP echo server example using raw API" and trying to
undrestand it. It creates a listening TCP connection, receives a
packet, sends it back and then closes the connection.
In the initialization function, accept callback is registered in lwip
echo_pcb = tcp_new();
echo_pcb = tcp_listen(echo_pcb);
Connection is closed by the server after each echo session,
echo_close(struct tcp_pcb *tpcb, struct echo_state *es)
tcp_poll(tpcb, NULL, 0);
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.
But this doesn't happen for accept callback.
Please tell me, what am I missing here?
|[Prev in Thread]
||[Next in Thread]|
- [lwip-users] Raw TCP API: question about tcp_close and accept callback in,
Хазанский Роман <=