Registry / devops / tcp-client

tcp-client

JSON →
library1.1.9jsnpmunverified

tcp-client is a minimal Node.js TCP client that provides a callback-based interface for sending requests and receiving responses. The current version 1.1.9 (last updated 2016) is stable but lacks active maintenance. It differs from full-featured TCP libraries (e.g., net module or generic-pool) by offering a simple wrapper with automatic logging of sent and received data, but lacks promises, TypeScript types, and modern JS features. Suitable only for simple synchronous-style TCP communication in legacy projects.

npm install tcp-client
INSTALL
IMPORT
SIG · TCP-CLIENT
T
tcp-client
devopsjavascriptv1.1.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (module)
const tcpClient = require('tcp-client')
import tcpClient from 'tcp-client'
The package does not ship ES modules; only CommonJS require works. ESM import fails unless using bundler or ESM wrapper.
createClient
const client = tcpClient.createClient(options)
import { createClient } from 'tcp-client'
createClient is a method on the default export. Named import is not supported.
client.request
client.request(data, callback)
client.request(data).then(...)
The library uses callbacks, not promises. Promisify manually if needed.

This example creates a TCP client, sends a buffer to the server, and handles the callback with error or response.

const tcpClient = require('tcp-client'); const options = { ip: '192.168.1.100', port: '6777', timeout: '5000' }; const client = tcpClient.createClient(options); const tramaEnvio = Buffer.from('hello server'); client.request(tramaEnvio, function (err, response) { if (err) { console.error('TCP request failed:', err); return; } console.log('Response:', response.toString()); });
Debug
Known issues
breakingPackage name misspelled as 'tpc-client' in readme; npm package is 'tcp-client'. Installation fails if using misspelled name.
fix
Use correct npm package name: npm install tcp-client
affects: *
gotchaTimeout property must be a string, not number. Setting timeout as number may cause unexpected behavior.
fix
Set timeout as string: options.timeout = '5000'
affects: 1.x
gotchaTCP response is returned as a Buffer. Attempting to treat it as a string without conversion may lead to errors.
fix
Use response.toString() or explicitly handle Buffer.
affects: *
deprecatedPackage uses callback pattern; no promise support. Mixing promises will break.
fix
Wrap in util.promisify or use a different library that supports promises.
affects: *
Errors
Common errors & fixes
Error: connect ETIMEDOUT
TCP connection timed out due to incorrect IP, port, or network issue.
fix
Verify the server IP and port, increase timeout value, and ensure the server is reachable.
TypeError: Cannot read property 'request' of undefined
The module import failed, likely due to using ESM import syntax (import tcpClient from ...).
fix
Use CommonJS require: const tcpClient = require('tcp-client').
Upgrade
Version history
1.1.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
tcp-client — npm install tcp-client · libregistry