Dear all,

I'm trying to access a TCP socket from multiple threads. One thread is
listening for incoming data while multiple threads are submitting data.

I've learned and understood from other postings that lwIP's sockets
are not thread safe, so I protected the calls to the send routine with
a mutex.
The receiving thread, however, blocks waiting for incoming data so I
can't use the mutex for that. But without protection, the application
crashes if there is a send call from another thread while a receive
call is active.

I resolved the issue by blocking the receive thread using an
unprotected call to select(), waiting for incoming data. Then, after
the thread has unblocked, doing a protected call to recv() that
fetches the data from lwIP.

What do you think about that? It seems to work for me but is it safe?
Or might the select() call also interfere with send() in a way that
makes the application crash at some point?

Any advice is appreciated.

Thanks,
Steffen

_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to