Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

FreeRTOS+TCP sockets in multiple threads.

Posted by captainjerk on July 14, 2016

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.

Posted by rtel on July 14, 2016

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.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS