lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Closing TCP connections


From: Mark Lvov
Subject: [lwip-users] Closing TCP connections
Date: Wed, 30 Jul 2014 23:31:07 +0400

Hello,

I am using raw API, LWIP version is 1.4.1.

I am unsure, how to properly handle closing connections. I am considering the following cases:
* passive close - remote host decided, that he is done with us and sent FIN. We see it, when we receive a NULL pbuf. Is the pcb deallocated by that time? Do we have to do anything else to fully terminate the connection or can we just stop referring to that pcb and ask for a new one? It seems, one has to only return ERR_OK from the callback.
* active close - we call tcp_close (which will result in sending a segment with FIN set) and if it succeeds wait for the connection to really close. Then, as I've observed, things can progress in two ways: recv callback is called with a NULL pbuf and we proceed as above OR err callback is called. Whats the difference between these two behaviours? I guess, err callback is called when the remote host sends a RST, is that correct?

Anyway, once we arrive either at a recv callback with a NULL pbuf or the err callback, what's there to do with regards to the current connection (and the current pcb)? Can we just lose the reference to it and ask for the new one (so we can use it to reconnect)? If I call tcp_close and it succeeds, but the remote side never sends FIN | ACK, will some callback (err?) be called at some point? Do I need to monitor this condition (by keeping a timeout) myself?

Thanks in advance!
Mark

reply via email to

[Prev in Thread] Current Thread [Next in Thread]