[lwip-users] How to enable KEEP-ALIVE

1,279 views
Skip to first unread message

narke

unread,
Dec 11, 2011, 9:17:03 AM12/11/11
to Mailing list for lwIP users
Hi,

In raw API. I am confused how to enable the tcp KEEP-ALIVE feature.
It's seems the LWIP_TCP_KEEPALIVE switch is not designed for turning
on or off the feature. It's just for using or not using "keep_intvl"
and "keep_cnt" fields of a pcb. To my understanding, turning on or
off the LWIP_TCP_KEEPALIVE switch, makes no difference to the final
result.

And, according to the 1.4.0 code, the keep-alive segments will be sent
out only if the so_options of a pcb has a SOF_KEEPALIVE bit set. The
problem is, I don't find a place in the code that SOF_KEEPALIVE (or
SO_KEEPALIVE) was set.

Can anyone give me some explanations?

Thanks in advance.


--
Life is the only flaw in an otherwise perfect nonexistence
    -- Schopenhauer

narke
public key at http://subkeys.pgp.net:11371 (narke...@gmail.com)

_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Kieran Mansley

unread,
Dec 13, 2011, 3:31:06 PM12/13/11
to Mailing list for lwIP users

On 11 Dec 2011, at 14:17, narke wrote:

> Hi,
>
> In raw API. I am confused how to enable the tcp KEEP-ALIVE feature.
> It's seems the LWIP_TCP_KEEPALIVE switch is not designed for turning
> on or off the feature. It's just for using or not using "keep_intvl"
> and "keep_cnt" fields of a pcb. To my understanding, turning on or
> off the LWIP_TCP_KEEPALIVE switch, makes no difference to the final
> result.
>
> And, according to the 1.4.0 code, the keep-alive segments will be sent
> out only if the so_options of a pcb has a SOF_KEEPALIVE bit set. The
> problem is, I don't find a place in the code that SOF_KEEPALIVE (or
> SO_KEEPALIVE) was set.

It's part of the sockets API so there isn't a supported way to set it via the raw API, but you can probably get what you want by doing

pcb->so_options |= SOF_KEEPALIVE;

In general modifying pcb fields directly is discouraged but in this case there isn't an easy alternative. We should probably add a function to allow users to set these options in a supported manner.

Kieran

gold...@gmx.de

unread,
Dec 13, 2011, 3:59:35 PM12/13/11
to Mailing list for lwIP users
Kieran Mansley wrote:
> It's part of the sockets API so there isn't a supported way to set it via the raw API, but you can probably get what you want by doing
>
> pcb->so_options |= SOF_KEEPALIVE;
>
> In general modifying pcb fields directly is discouraged but in this case there isn't an easy alternative. We should probably add a function to allow users to set these options in a supported manner.

We definitively should! I added a bug entry targeted to 1.4.1 to do so.

Simon

narke

unread,
Dec 22, 2011, 8:13:19 AM12/22/11
to Mailing list for lwIP users
On 14 December 2011 04:31, Kieran Mansley <kie...@recoil.org> wrote:
>
> On 11 Dec 2011, at 14:17, narke wrote:
>
>> Hi,
>>
>> In raw API.  I am confused how to enable the tcp KEEP-ALIVE feature.
>> It's seems the LWIP_TCP_KEEPALIVE switch is not designed for turning
>> on or off the feature. It's just for using or not using "keep_intvl"
>> and "keep_cnt" fields of a pcb.   To my understanding, turning on or
>> off the LWIP_TCP_KEEPALIVE switch, makes no difference to the final
>> result.
>>
>> And, according to the 1.4.0 code, the keep-alive segments will be sent
>> out only if the so_options of a pcb has a SOF_KEEPALIVE bit set.  The
>> problem is, I don't find a place in the code that SOF_KEEPALIVE (or
>> SO_KEEPALIVE) was set.
>
> It's part of the sockets API so there isn't a supported way to set it via the raw API,  but you can probably get what you want by doing
>
> pcb->so_options |= SOF_KEEPALIVE;
>
> In general modifying pcb fields directly is discouraged but in this case there isn't an easy alternative.  We should probably add a function to allow users to set these options in a supported manner.
>
> Kieran


Thanks Kieran. I just had already found my way and did it exactly as
what you said.

--
Life is the only flaw in an otherwise perfect nonexistence
    -- Schopenhauer

_______________________________________________

Reply all
Reply to author
Forward
0 new messages