Replace TCP connections in a Go game server to reduce latency while keeping reliable ordered packet delivery.
Build a file synchronization tool that transfers data faster than TCP using kcp-go's low-latency UDP protocol.
Add packet-level AES or Salsa20 encryption to a UDP data stream without modifying application logic.
kcp-go is a Go library that provides reliable, ordered data delivery over UDP (User Datagram Protocol). UDP is a fast but normally unreliable way to send data across a network. TCP, the alternative, provides reliability but adds latency through its connection setup and acknowledgment mechanisms. kcp-go adds ordering, error checking, and guaranteed delivery on top of UDP while keeping response times lower than TCP allows. The library is designed for situations where speed matters more than bandwidth efficiency, such as online games, live video broadcasts, file synchronization tools, and network acceleration programs. It has been deployed across millions of devices, from low-end home routers to high-end servers. The code is compatible with Go's standard network interfaces, so it can replace a regular TCP connection in existing code without major rewrites. Beyond basic reliable delivery, kcp-go includes forward error correction using Reed-Solomon codes. This technique sends extra redundancy data alongside each message, allowing the receiver to reconstruct lost packets without waiting for a retransmission. The library also supports packet-level encryption with several algorithm options including AES, Blowfish, and Salsa20. Encryption is applied to the complete packet including headers, making it harder to analyze or tamper with traffic in transit. On the performance side, the library handles more than 5,000 concurrent connections on a single commodity server. The README documents the design choices behind this: using contiguous memory slices rather than linked lists for cache efficiency, minimizing calls to the system clock, and drawing memory from a global pool to avoid unnecessary allocations. On Linux, batch send and receive system calls are available to reduce per-packet overhead further. The library is licensed under MIT.
← xtaci on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.