Skip to content

[BUG] getaddrinfo doesn't fill ai_protocol #16693

Closed

Description

@yamt

Description / Steps to reproduce the issue

consider using getaddrinfo with
hints.ai_family == AF_INET
hints.ai_socktype == SOCK_STREAM
hints.ai_protocol == 0

i expect the result contains ai_protocol == IPPROTO_TCP.
but nuttx seems to leave it to 0.

standard-wise, the nuttx behavior might or might be allowed. (i haven't checked.)

anyway, i guess it's better to follow the de-fact behavior (kame etc) for compatibility for applications.
for example, wamr seems to have the assumption.

On which OS does this issue occur?

[OS: Mac]

What is the version of your OS?

macOS 15.5

NuttX Version

master

Issue Architecture

[Arch: simulator]

Issue Area

[Area: Networking]

Host information

No response

Verification

  • I have verified before submitting the report.

Activity

  1. added
    Type: Bug
    on Jul 8, 2025
  2. added
    Arch: simulator
    Area: Networking
    OS: Mac
    on Jul 8, 2025
  3. yamt commented on Jul 9, 2025

    @yamt
    ContributorAuthor

    standard-wise, the nuttx behavior might or might be allowed. (i haven't checked.)

    standard-wise, i couldn't find anything about ai_protocol in susv4-2018 except the following text:

    The fields ai_family, ai_socktype, and ai_protocol shall be usable
    as the arguments to the socket() function to create a socket suitable
    for use with the returned address.
    

    because ai_protocol is usually merely used to feed socket() and socket() usually accepts 0, it's probably standard-wise ok for getaddrinfo to return ai_protocol=0.

  4. added 8 commits that reference this issue on Oct 15, 2026
    4ad088a
    7264b61
    110a9c8
    8ea0073
    d9d3448
    fee3630
    1804549
    57c1659
  5. added a commit that references this issue on Oct 25, 2026
    345643d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: simulatorArea: NetworkingOS: MacType: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions