Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix declaration of socket functions without TCP #1068

Merged
merged 6 commits into from
Jan 9, 2024

Conversation

HTRamsey
Copy link
Contributor

@HTRamsey HTRamsey commented Dec 30, 2023

Fix declaration of socket ID functions without TCP

Description

These functions were limited to when TCP was enabled only, but weren't reliant on TCP.
Side note - Shouldn't these functions be named like an API function such as FreeRTOS_SetSocketID/FreeRTOS_GetSocketID?
And perhaps there should be a config like ipconfigSUPPORT_SOCKET_ID or something to remove the void * pvSocketID in the xSOCKET struct if not needed.

Test Steps

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@HTRamsey HTRamsey requested a review from a team as a code owner December 30, 2023 11:26
@HTRamsey HTRamsey changed the title Fix declaration of socket ID functions without TCP Fix declaration of socket functions without TCP Dec 31, 2023
Copy link
Contributor

@htibosch htibosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@holden-zenith , thank for noticing this. You are right, socket ID's can also be used in UDP-only applications.

The socket ID is used in a wide variety of situations. UDP sockets also have callbacks, and users can assign an ID.

C++ programmers will typically assign the address of an object to the socket ID.

This feature is always available, it does not depend on some ipconfig flag. We decided to do so because the memory foot print is extremely small, and we didn't like yet another #if.

Shouldn't these functions be named like an API function such as FreeRTOS_SetSocketID/FreeRTOS_GetSocketID?

Yes maybe we should have done so, although the name would get long: FreeRTOS_SocketGetSocketID().

The FreeRTOS_ prefix was originally only used for the standard BSD functions:

    FreeRTOS_socket()
    FreeRTOS_listen()
    FreeRTOS_bind()
    FreeRTOS_recv()
    FreeRTOS_send()

I often have ported a program to Linux by defining :

    #define FreeRTOS_socket  socket
    #define FreeRTOS_listen  listen

and vice versa:

    #define socket  FreeRTOS_socket
    #define listen  FreeRTOS_listen

@tony-josi-aws tony-josi-aws merged commit 280dd14 into FreeRTOS:main Jan 9, 2024
10 checks passed
@HTRamsey HTRamsey deleted the dev-sockets branch January 10, 2024 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants