APTCP protocol maintains TCP session during IP changes and connection interruptions
The author developed APTCP—a protocol built on top of standard TCP—that conceals reconnections and IP changes from applications. Implementations are available for Go and Python.

APTCP separates the physical TCP connection from the logical socket. If the channel is interrupted, the socket enters a waiting mode: new data is buffered, and read operations wait for the connection to be restored without errors. After reconnection, the parties confirm the session using HMAC-SHA256 and resend lost data. The write buffer is designed to hold up to 5 MB.
The protocol is intended for applications requiring a single data stream, such as for Read/Write calls or forwarding an individual TCP connection. Its specification is published under the Apache 2.0 license, and the library is implemented in Go and Python. The author first tested the finite state machine and mathematics in the aioptcp prototype before preparing the ptcp_go implementation.
APTCP is designed to function where standard TCP passes through NAT, proxies, and load balancers, while UDP may be blocked. Unlike Mosh and Eternal Terminal, the protocol is not limited to terminal sessions; WireGuard requires a network tunnel and administrator privileges. QUIC supports connection migration but uses UDP and stream multiplexing, which are not necessary for every application. APTCP maintains a single stream and familiar TCP diagnostic tools.





