Skip to content

[Feature Request] Add vTimerSetTimerID/pvTimerGetTimerID equivalents for sockets. #543

@karver8

Description

@karver8

Is your feature request related to a problem? Please describe.
There is no easy way to locate application data associated with a socket from a socket callback.

Sockets allow the application to set callback functions for various events, e.g. FREERTOS_SO_TCP_RECV_HANDLER which will call a function with the prototype BaseType_t (* FOnTCPReceive_t )( Socket_t xSocket, void * pData, size_t xLength ). However if the same callback function is assigned to multiple sockets, there is no easy way to "identify" the socket using just its handle. You could define a data structure containing sockets paired with their associated objects and search through this, however this is not very efficient.

Describe the solution you'd like
Add vTimerSetTimerID/pvTimerGetTimerID equivalents to the sockets API and add a void * pvSocketID member to the IPTCPSocket_t struct.

These could look like:

  • vSocketSetSocketID/pvSocketGetSocketID
  • FreeRTOS_setsocketid/FreeRTOS_getsocketid (more in line with the libraries naming style)

Describe alternatives you've considered
A SOCKET_ID option could be added to FreeRTOS_setsockopt(), and the callback prototypes could be modified to include the socket ID. This however ruins backwards compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions