Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

node-kcp-x

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-kcp-x

KCP protocol for Node.js

latest
Source
npmnpm
Version
1.2.3
Version published
Weekly downloads
35
34.62%
Maintainers
1
Weekly downloads
 
Created
Source

node-kcp-x

| English | 简体中文 |

KCP Protocol for Node.js

A fork of node-kcp, rewritten using node-addon-api

Features

  • High Performance: 30%-40% reduction in average RTT compared to traditional ARQ protocols like TCP
  • Low Latency: Maximum RTT reduced by 3x compared to TCP
  • Lightweight: Distributed as a single source file
  • Modern API: Built with node-addon-api for better Node.js compatibility
  • Cross Platform: Supports Windows, Linux, and macOS

Installation

npm install node-kcp-x

Building from Source

Prerequisites

npm install -g node-gyp prebuildify

Build Steps

git clone https://github.com/bruce48x/node-kcp
cd node-kcp
npm i
npm run build

Usage Examples

Example 1: Basic UDP Test

npm run install
node test/udpserver.js
node test/udpclient.js

Example 2: Client-Server Communication

# Run server
node examples/server.js
# Run client
node examples/client.js

Example 3: Stream Mode

# Run stream server
node examples/stream-server.js
# Run stream client
node examples/stream-client.js

API Reference

KCP Class

const kcp = require('node-kcp-x');
const Kcp = kcp.KCP;

// Create KCP instance
const kcpObj = new Kcp(conv, context);

// Set output callback
kcpObj.output((data, size, context) => {
    // Send data to network
});

// Send data
kcpObj.send(buffer);

// Receive data
const buffer = kcpObj.recv();

// Update KCP state
kcpObj.update(timestamp);

// Check next update time
const nextUpdate = kcpObj.check(timestamp);

About Pomelo and Pomelo-kcp

If you want to use node-kcp in pomelo server, you need pomelo-kcp

License

Apache-2.0

Keywords

kcp

FAQs

Package last updated on 12 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts