[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] peer hangs up without closing the connection
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] peer hangs up without closing the connection |
Date: |
Fri, 7 Feb 2014 08:17:06 +0100 |
Robert Wessels wrote:
> [..]
> I have tried using the keep alive feature of LwIP but that does not quite do
> the trick. Timeout’s are to long and without modifying those I won’t be able
> to bend it to my needs.
>
> What I am thinking of implementing is my own keep alive. When the client
> connects successfully I set the tcp_poll callback to be called every 5
> seconds. In the poll callback I call tcp_keepalive() and increase
> pcb->keep_cnt_sent by one. I check pcb->keep_cnt_sent every time the poll
> callback is called. If pcb->keep_cnt_sent reaches a certain number then I
> consider the connection to be dead and shutdown the connection.
>
> Does that sound reasonable? Would sending a keep alive probe every 5 seconds
> be considered abusive? Any other way to accomplish this?
You are not the only one with this problem, as this is one often found by TCP
"beginners": the protocol is simply not designed to quickly discover connection
breaks but rather to reliably survive them.
Your self-designed timeout sounds like a good idea. However, using lwIP's
internal state is not a door design choice. You should never directly use the
members of an lwIP struct: these are not guaranteed to remain compatible over
multiple versions, we only try to keep the function calls compatible.
Unfortunately, we have to make the structs public to be able to create
function-like defines for small code, but that doesn't mean the struct members
should be "public"... Thats a C problem, though...
Keeping that aside, why don't you just create your own timeout using the pcb's
"arg"?
Simon