Skip to content

Configure TCP buffers and make flushing explicit - #207

Draft
wangxiao1254 wants to merge 2 commits into
mainfrom
fix/wan-socket-policy
Draft

wangxiao1254 wants to merge 2 commits into
mainfrom
fix/wan-socket-policy

Conversation

@wangxiao1254

Copy link
Copy Markdown
Member

Summary

Make transport buffering configurable before connection setup and give flush() one precise meaning: drain local output.

Changes

  • add tcp::SocketOptions with explicit send/receive buffer sizes;
  • add bandwidth/RTT-derived sizing with a 256 KiB floor and power-of-two tiers;
  • apply and verify options before listen/connect and before the TLS handshake;
  • propagate the same policy to NetIO::make_sibling();
  • expose socket options through TLSConfig and require defaults for adopted TLS sockets;
  • remove the transport-level sync() hook;
  • replace test synchronization with explicit marker round trips;
  • report NetIO fflush failures;
  • make TraceIO reject null transports, create trace files with mode 0600, flush traces before the wrapped channel, and report write/flush failures.

API migration

IOChannel::sync() is removed.

  • Call flush() when the protocol needs to drain locally buffered output.
  • Exchange an explicit protocol message when the protocol needs a peer barrier or round trip.

EMP-OT has a coordinated migration that replaces its remaining synchronization calls with explicit flushes.

Zero-valued socket options retain the operating-system defaults. Explicit buffer requests fail if the kernel cannot provide the requested minimum.

Tests

  • clean Apple Clang 17 Release/Ninja build: 90/90 build steps;
  • full CTest suite: 53/53 passed;
  • focused test_netio, test_tlsio, and test_traceio: 3/3 passed.

Coverage includes buffer derivation, unavailable-buffer rejection, listener/client/sibling inheritance, TLS socket settings, adopted-socket rejection, explicit sibling round trips, send-only draining, ignored flush errors, TraceIO delegation, trace flushing, and file permissions.

Stack

This is PR 2 of 6 and targets fix/byte-bool-api. After PR 1 merges, this PR can be retargeted to main without changing its diff.

@wangxiao1254
wangxiao1254 changed the base branch from fix/byte-bool-api to main August 23, 2026 02:20
Expose explicit send and receive socket-buffer sizes through NetIO and TLSConfig. Apply them before listen/connect and the TLS handshake, propagate them to NetIO siblings, and leave operating-system defaults unchanged when both values are zero.

Provide an opt-in bandwidth/RTT helper that rounds the bandwidth-delay product to a power-of-two tier and reject explicit sizes the kernel cannot provide.
@wangxiao1254
wangxiao1254 force-pushed the fix/wan-socket-policy branch from fa0fedd to 3c84449 Compare August 23, 2026 02:21
Comment thread test/runtime/test_traceio.cpp Fixed
Comment thread test/runtime/test_traceio.cpp Fixed
Remove the transport-level sync hook and preserve connection coverage with explicit protocol round trips. Callers that need a peer barrier must exchange a protocol message; flush only drains local output.

Fail on NetIO stdio flush errors. Make TraceIO reject null transports, flush its trace before the wrapped channel, create trace files with mode 0600, and report trace write and flush failures.
@wangxiao1254
wangxiao1254 force-pushed the fix/wan-socket-policy branch from 3c84449 to 030bf9e Compare August 23, 2026 02:45
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.

2 participants