Page 1 of 1

Concurrent socket usage from multiple tasks

Posted: Tue Feb 21, 2017 9:49 pm
by kolban
We are now starting to get into what I would consider to be more advanced concepts. Here is one I put forward to us as a community ... are sockets thread safe with respect to reading and writing?

Imagine I have a FreeRTOS task that invokes a socket recv() API call and is blocked waiting for incoming TCP data. Now imagine a second task that is running in parallel to the first. Is this second task allowed to make a TCP send() API call on the SAME socket while the other task is blocked on a recv()?

Re: Concurrent socket usage from multiple tasks

Posted: Wed Feb 22, 2017 1:39 am
by ESP_Angus
Yes, this should work. The receiving task will remain blocked until the other end of the TCP connection has sent data.