FreeRTOS+TCP sockets in multiple threads.

Hello. What I want to achieve is to have multiple threads, each responsible for its own protocol. I am starting two threads and initialize two queues (Q1, Q2) (to pass the messages through them). Upon receiveing the message from queue, thread is supposed to open a socket, dump the message and eventually close the connection. What actually happens is, when I post messages like this: xQueueSend(Q1, msg1, 0) delay xQueueSend(Q2, msg2, 0) Everything works and both remote servers receive messages, but if no delay inserted, then one thread (I guess the one that calls FreeRTOSconnect later) fails to connect (connect() always returns ERRNOTIMEOUT). What could be wrong? Does not sockets supposed to work simultaneous?

FreeRTOS+TCP sockets in multiple threads.

I’m afraid there is not enough information in your post to fully understand your usage scenario, or how you are using the sockets, to be able to provide a full answer. As far as using sockets from multiple threads go: Any number of threads (tasks) can use FreeRTOS+TCP at any time, however there is a restriction on how tasks can share a single socket as follows: If you use the SAME socket from more than one thread then only one of the threads can write to the socket and only one of the threads can read from the socket – you can not have more than one thread both reading to and writing from the SAME socket.