lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Sending with thread safety


From: Mike He
Subject: [lwip-users] Sending with thread safety
Date: Mon, 06 Jul 2015 12:08:59 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

Hello,

I am looking for some help understanding the proper way to send packets with lwIP while maintaining thread safety. As I understand from the documentation, using raw API, I have to call lwIP functions from inside lwIP's execution context.

For operating in server mode, this is easy to understand and is well-documented in the examples given. When a request is received, the response is sent back in the tcp_recv callback, so all the code is in lwIP's context.

However, for sending data with lwIP that is not the response of a request - for example as a client, or as part of a full-duplex protocol such as Websocket - the trigger to send a packet in these cases is initiated by something outside the lwIP context, and I am not sure the proper way to bring the packet into the lwIP context. Assuming the connection is set up already, then to send a packet, the documentation says to call tcp_write to enqueue and tcp_output to send.

1. Where is the proper place to call these functions in the lwIP context? Is it in the lwIPHostTimerHandler? 2. Do I need to call both tcp_write and tcp_output in the lwIP context? Or can I enqueue with tcp_write outside of the context, and just call tcp_output from inside the lwIP context? 3. Is the basic procedure then to set a flag from outside the context (passing any data through global or file scope), then call the lwIP functions from inside its execution context?

Thanks for any help,
Mike



reply via email to

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