feat(runtime): socket option natives for TCP streams #427
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/426-socket-option-natives"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #426
Step 1 of #120: the runtime can set and read the TCP options of a connected stream, behind two new natives. No
std/source changes, so the seed that builds the compiler still compiles everything.What
torb_network_set_option(stream, option, value)andtorb_network_option(stream, option)inruntime/io.c, declared inruntime/include/torb_network.hwith the option table (0TCP_NODELAY, 1SO_KEEPALIVE, 2 idle time, 3 probe interval, 4 probe count). A value below 1 for options 2 to 4 isinvalid argument; a closed handle or a listener isclosed.torb_io_system_set_option/torb_io_system_optionbesidetorb_io_system_shutdown:runtime/os/posix_io.c(TCP_KEEPIDLE,TCP_KEEPALIVEon macOS,TCP_KEEPINTVL,TCP_KEEPCNT) andruntime/os/iocp.c(Windows 10 1709 and later through the resolvedsetsockoptand a newly resolvedgetsockopt; noSIO_KEEPALIVE_VALSfallback).networkSetOptionandnetworkOptioninnativeEntries();torb_natives.handmachine_natives.cupdated; twokeep/networkrows and the counts indocs/design/NATIVES.md;docs/design/NETWORK.mdsection 4 points at this slice with the option table.runtime/tests/io_test.c: flags set and read back, keepalive times and count set and read back, 0 refused, closed handle and listener fail.Seed
Touches the seed: yes (new natives in the manifest). This is the first of the two commits of that rule ("teach the form"); the seed refresh and publishing are for the merge gate and Torben, step 2 of #120 follows once the published seed knows the natives.
Test
Nothing was built or run locally (loop rule: gates, bootstrap and runtime build only in forge CI).
tools/check-commits.sh origin/mainis clean.runtime/machine_natives.candtorb_natives.hwere updated by a script that follows the generator's rules (sorted by symbol, thunks renumbered) instead of a localtorb natives --header; the generated-file check in CI passed.Forge CI on
e0eb950c(run 1438): tier A, tier B, gates (sh tools/gates.sh a/b), bootstrap, commit messages, pdisc, playground and same-C all green. A first push failed in the bootstrap because the option enum typedef shared its name with the function; renamed totorb_network_option_numberand amended (still one commit).62f981a539e0eb950c87Checklist (head
e0eb950):Non-blocking: none. Merging by rebase.
TCP_NODELAY, keepalive) #120TCP_NODELAY, keepalive) #120TCP_NODELAY, keepalive) #120