Skip to content

Conversation

@amyssnippet
Copy link

@amyssnippet amyssnippet commented Jan 24, 2026

this PR implements socket.setTOS(tos) and socket.getTOS() in net.Socket. it needed this to support DSCP tagging (QoS) for traffic prioritization, which wasn't previously exposed in the JS API. for the implementation:

  • I added the logic in tcp_wrap.cc to attempt IP_TOS first, and fallback to IPV6_TCLASS if that fails. This handles both IPv4 and IPv6 sockets automatically without needing a separate flag.
  • Windows returns UV_ENOSYS for now since the headers/implementation differ there.
  • Added a new test file (test-net-socket-tos.js) to verify input validation and ensure the values are actually set on supported platforms.

Fixes: #61489

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jan 24, 2026
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Good work. Can you add the documentation?

@mcollina mcollina requested a review from ronag January 24, 2026 13:16
@mcollina mcollina added the semver-minor PRs that contain new features and should be released in the next minor version. label Jan 24, 2026
@amyssnippet amyssnippet requested a review from mcollina January 24, 2026 13:41
@amyssnippet amyssnippet mentioned this pull request Jan 24, 2026
@amyssnippet amyssnippet requested a review from mcollina January 24, 2026 14:34
@amyssnippet
Copy link
Author

Thanks @mcollina , is this ready to be merged? Please let me know if there is anything else you need me to adjust.

@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 25, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 25, 2026
@nodejs-github-bot
Copy link
Collaborator

@ronag
Copy link
Member

ronag commented Jan 25, 2026

@mcollina I'm confused by the CI failures. Any ideas? Or just flaky?

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@amyssnippet
Copy link
Author

i have fixed all issues from my side, on both linux and windows. all platforms are ready to get served with the 26 pre version. rest ci failures are flaky. Thanks!

@amyssnippet amyssnippet requested review from addaleax and ronag and removed request for ronag January 27, 2026 16:16
Copy link
Member

@juanarbol juanarbol left a comment

Choose a reason for hiding this comment

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

I think windows may need a different implementation, with a different API.

Do not use. Type of Service (TOS) settings should only be set using the Quality of Service API. See Differentiated Services in the Quality of Service section of the Platform SDK for more information.

https://learn.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options

@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 28, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 28, 2026
@nodejs-github-bot
Copy link
Collaborator

@amyssnippet
Copy link
Author

so is everything fine and ready to merge???

@amyssnippet amyssnippet reopened this Jan 28, 2026
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm but there are still a few comments to solve

@amyssnippet
Copy link
Author

@mcollina likely the renaming ones right??

i have pushed the changes regarding the renaming ones, have a look at it, i was just waiting to see that all ci checks are running properly or not for all platforms.

@amyssnippet amyssnippet requested review from addaleax, anonrig, juanarbol, mcollina and ronag and removed request for anonrig January 28, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

socket.setTOS

8 participants