Skip to content

feat: add ResetRTO API for immediate recovery#344

Open
lonnywong wants to merge 1 commit into
xtaci:masterfrom
lonnywong:master
Open

feat: add ResetRTO API for immediate recovery#344
lonnywong wants to merge 1 commit into
xtaci:masterfrom
lonnywong:master

Conversation

@lonnywong

@lonnywong lonnywong commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #343.

Introduces ResetRTO() to help applications quickly resume data delivery once they detect that network connectivity has been restored.

This is highly beneficial in mobile or volatile network environments. When the application detects link restoration (e.g., cellular to Wi-Fi handover) via out-of-band signals, it can use this API to resume data delivery immediately without waiting for long penalizing RTO timers to expire.

Implement `ResetRTO` at both the `KCP` and `UDPSession` levels to reset
retransmission timers for all unacknowledged segments.

When network connectivity is restored after an interruption, existing
retransmission timers might have exponentially backed off, causing
unnecessary delays. This feature allows the application layer to hint
the underlying session to reset the RTO and schedule retransmissions
immediately.

By design, `UDPSession.ResetRTO()` avoids a synchronous `flush` to
prevent immediate I/O bursts and minimize lock contention. The actual
retransmissions are naturally picked up by the background `update()`
tick, governed by the configured `interval` (e.g., 10ms-100ms via
SetNoDelay), providing a smooth and predictable recovery.
@lonnywong lonnywong changed the title feat: add ForceRetransmit API to UDPSession for immediate recovery feat: add ResetRTO API for immediate recovery Jun 14, 2026
lonnywong added a commit to trzsz/kcp-go that referenced this pull request Jun 20, 2026
Changed the module path directly instead of using a replace directive,
as `go install` does not support `go mod replace`. This ensures downstream
users can install and build the binary properly via `go install`.

We will consider switching back to the upstream repository
if the maintainer merges the PR (kcp-go#344) in the future.
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.

【Feature Request】新增 ResetRTO() 接口以实现网络重连后的无缝快速恢复

1 participant