node-unix-socket is a Node.js addon, built with napi-rs and leveraging libuv, that extends Node.js's native networking capabilities to support Unix `SOCK_SEQPACKET` and `SOCK_DGRAM` sockets. It also enables the use of `SO_REUSEPORT` for TCP `net.Server` instances, offering an alternative to Node.js's built-in `cluster` module for load balancing, with kernel-level distribution. The package is currently at version 0.2.7, indicating ongoing development. It differentiates itself by providing these advanced socket types without introducing additional asynchronous runtimes, relying solely on Node.js's internal libuv. Pre-compiled binaries are shipped for common platforms, reducing the need for compilation environments. This library is particularly useful for inter-process communication patterns requiring message boundary preservation (seqpacket) or connectionless datagram communication, as well as optimizing high-throughput TCP servers. While release cadence isn't explicitly stated, its focus on specific, low-level features suggests a stable, less frequent update cycle unless major Node.js changes necessitate it.
npm install node-unix-socketVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up a SeqpacketServer and connect a SeqpacketSocket client to it, sending multiple messages while preserving message boundaries, then cleaning up the socket file.
Ensure your deployment environment for SOCK_SEQPACKET sockets is Linux. For cross-platform compatibility, consider alternative IPC mechanisms like standard TCP sockets or other specialized libraries.
Thoroughly test SO_REUSEPORT behavior on all target operating systems and Node.js versions. Consult OS-specific documentation and network stack behavior for accurate expectations. Implement robust monitoring to ensure connections are distributed as intended.
Check the project's supported platforms table in the README. Ensure your Node.js version, OS, and architecture match. If issues persist, refer to the `napi-rs` and Node.js N-API documentation for setting up a compilation environment, which may require specific toolchains (e.g., Python, C++ compiler, Node.gyp).
Rebuild the native modules for your current Node.js version by running `npm rebuild node-unix-socket` or `npm install` again. Ensure your Node.js version is supported by the package.
Double-check the socket path for validity and correct permissions. For `SOCK_SEQPACKET` or `SOCK_DGRAM` sockets, ensure the operating system (e.g., macOS for `SOCK_SEQPACKET`) actually supports the requested operation. Verify the path is absolute and within acceptable length limits for the OS.
Ensure the server is running and has successfully created the socket file at the specified path before the client attempts to connect. Verify the path used by the client exactly matches the path the server is binding to. Check file system permissions if the path exists but is inaccessible.
No dependency data recorded yet.