apache / apache/nuttx

[BUG] getaddrinfo doesn't fill ai_protocol

Open
#16,693 1 comment 0 reactions 0 assignees View on GitHub
Arch: simulator Area: Networking OS: Mac Type: Bug
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

### 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](https://github.com/bytecodealliance/wasm-micro-runtime/blob/d3b0b5c066e21ba3568448ad42e0b920e67d16ba/core/shared/platform/common/posix/posix_socket.c#L376-L377).

### 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

- [x] I have verified before submitting the report.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.