# FreeRTOS-Plus-TCP: FreeRTOS\_select incorrect return value documentation

**URL:** <https://forums.freertos.org/t/freertos-plus-tcp-freertos-select-incorrect-return-value-documentation/16333>\
**Category:** Libraries\
**Created:** [December 6, 2022, 9:06am UTC](https://forums.freertos.org/t/freertos-plus-tcp-freertos-select-incorrect-return-value-documentation/16333 "2022-12-06T09:06:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Igor\_Petrov](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@Igor\_Petrov](https://forums.freertos.org/u/Igor_Petrov)\
**Post date:** [December 6, 2022, 9:06am UTC](https://forums.freertos.org/t/freertos-plus-tcp-freertos-select-incorrect-return-value-documentation/16333/1 "2022-12-06T09:06:31Z")

</div>

I’m adding a signal functionality to TCP sockets and noticed a mismatch between the documentation and what the select function actually does.

The return value of FreeRTOS\_select is documented differently in 2 places and both of them seem to be incorrect:

1. [FreeRTOS\_select](https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/API/select.html) and [FreeRTOS\_SignalSocket](https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/API/FreeRTOS_SignalSocket.html) documentation state that FreeRTOS\_select returns -pdFREERTOS\_ERRNO\_EINTR if a socket in a set receives a signal. It never does that, it returns eSELECT\_INTR instead.

2. Comment in FreeRTOS\_Sockets.c state that returned value is:

```auto
@return The socket which might have triggered the event bit.

```

This is also not true, the select function returns event bits, not a socket.

---

<div class="post-metadata">

**Author:** ![kanherea](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/kanherea/32/4106_2.png) [@kanherea](https://forums.freertos.org/u/kanherea)\
**Post date:** [December 6, 2022, 10:26am UTC](https://forums.freertos.org/t/freertos-plus-tcp-freertos-select-incorrect-return-value-documentation/16333/2 "2022-12-06T10:26:46Z")

</div>

Hello @Igor_Petrov,

Thank you for catching this discrepancy in our documentation and notifying us about it. We will work on fixing this quickly. Note that we do not update the website every day and it will get updated with the next scheduled update (mostly within a week).

As far as the documentation in comments is concerned, would you like to [create a PR to the FreeRTOS-Plus-TCP](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/pulls) repository, or would you like us to do that on your behalf?

Thanks,  
Aniruddha

---

<div class="post-metadata">

**Author:** ![Igor\_Petrov](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@Igor\_Petrov](https://forums.freertos.org/u/Igor_Petrov)\
**Post date:** [December 6, 2022, 11:13am UTC](https://forums.freertos.org/t/freertos-plus-tcp-freertos-select-incorrect-return-value-documentation/16333/3 "2022-12-06T11:13:38Z")

</div>

Hello @kanherea  
I would prefer if you open a PR on my behalf

---

<div class="post-metadata">

**Author:** ![kanherea](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/kanherea/32/4106_2.png) [@kanherea](https://forums.freertos.org/u/kanherea)\
**Post date:** [December 8, 2022, 5:11am UTC](https://forums.freertos.org/t/freertos-plus-tcp-freertos-select-incorrect-return-value-documentation/16333/4 "2022-12-08T05:11:00Z")

</div>

Hello @Igor_Petrov,

We have opened a PR and are working on merging it. Here is the link to the PR if you would like to review it: [Updated comments for FreeRTOS\_select return value by tony-josi-aws · Pull Request #596 · FreeRTOS/FreeRTOS-Plus-TCP · GitHub](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/pull/596).

Additionally, we are working on updating the website description too. It should be updated with the next bulk update to the website.

Thanks again,  
Aniruddha

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [December 8, 2022, 5:16am UTC](https://forums.freertos.org/t/freertos-plus-tcp-freertos-select-incorrect-return-value-documentation/16333/5 "2022-12-08T05:16:23Z")

</div>

Hello @Igor_Petrov, thank you for mentioning the incorrect comments.

Are you using the signal function in your projects? If so, does it work properly for you?

The socket-signal function was added on request of a [wolfSSL](https://www.wolfssl.com/docs/ssl-library) user who wanted to interrupt a blocking call to `FreeRTOS_recv()`, in order to send a packet.

There are more ways to solve this, but in this case, a `xxxFromISR()` version was needed.

I tested this feature in a Xilinx project, which gets a hardware interrupt from a button. The GPIO interrupt will call `FreeRTOS_SignalSocketFromISR()`, which in case signals a socket.

---

<div class="post-metadata">

**Author:** ![Igor\_Petrov](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@Igor\_Petrov](https://forums.freertos.org/u/Igor_Petrov)\
**Post date:** [December 8, 2022, 8:27am UTC](https://forums.freertos.org/t/freertos-plus-tcp-freertos-select-incorrect-return-value-documentation/16333/6 "2022-12-08T08:27:10Z")

</div>

@htibosch, my use case is a little different.  
I’m implementing a single-task TCP server that serves a small number of clients. Basically this [Server socket example](https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial_TCP_Client_and_Server.html), but instead of spawning a new task for the connected client, I have a socket set that contains listening socket and all connected clients. I wait by `FreeRTOS_select` for the incoming connection or data. If select unblocks because of `eSELECT_READ` event on the listening socket, I accept the connection, and add the accepted socket to the list of clients and to the socket set; else I search the list of connected clients for the socket that has `eSELECT_READ` set, read the data, process it and send the reply.

At some point during the program’s runtime, I need to shut down the server and gracefully close all connections. So there’s another task that sends the signal by `FreeRTOS_SignalSocket` to the listening socket indicating that it’s time to close everything and delete the server task. Of course, this could be implemented by setting a short blocking time in `FreeRTOS_select` call and pooling some flag, but I wanted to minimize pooling overhead and latency.

So far It works petty well. However, I haven’t tried to unblock `FreeRTOS_recv` calls or sent signals from ISR.
