{"id":42073,"library":"tcp-client","title":"tcp-client","description":"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.","status":"maintenance","version":"1.1.9","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","tcp","client"],"install":[{"cmd":"npm install tcp-client","lang":"bash","label":"npm"},{"cmd":"yarn add tcp-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add tcp-client","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package does not ship ES modules; only CommonJS require works. ESM import fails unless using bundler or ESM wrapper.","wrong":"import tcpClient from 'tcp-client'","symbol":"default (module)","correct":"const tcpClient = require('tcp-client')"},{"note":"createClient is a method on the default export. Named import is not supported.","wrong":"import { createClient } from 'tcp-client'","symbol":"createClient","correct":"const client = tcpClient.createClient(options)"},{"note":"The library uses callbacks, not promises. Promisify manually if needed.","wrong":"client.request(data).then(...)","symbol":"client.request","correct":"client.request(data, callback)"}],"quickstart":{"code":"const tcpClient = require('tcp-client');\n\nconst options = {\n  ip: '192.168.1.100',\n  port: '6777',\n  timeout: '5000'\n};\n\nconst client = tcpClient.createClient(options);\n\nconst tramaEnvio = Buffer.from('hello server');\nclient.request(tramaEnvio, function (err, response) {\n  if (err) {\n    console.error('TCP request failed:', err);\n    return;\n  }\n  console.log('Response:', response.toString());\n});","lang":"javascript","description":"This example creates a TCP client, sends a buffer to the server, and handles the callback with error or response."},"warnings":[{"fix":"Use correct npm package name: npm install tcp-client","message":"Package name misspelled as 'tpc-client' in readme; npm package is 'tcp-client'. Installation fails if using misspelled name.","severity":"breaking","affected_versions":"*"},{"fix":"Set timeout as string: options.timeout = '5000'","message":"Timeout property must be a string, not number. Setting timeout as number may cause unexpected behavior.","severity":"gotcha","affected_versions":"1.x"},{"fix":"Use response.toString() or explicitly handle Buffer.","message":"TCP response is returned as a Buffer. Attempting to treat it as a string without conversion may lead to errors.","severity":"gotcha","affected_versions":"*"},{"fix":"Wrap in util.promisify or use a different library that supports promises.","message":"Package uses callback pattern; no promise support. Mixing promises will break.","severity":"deprecated","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.1.9':29 '2016':32 'activ':37 'automat':60 'base':18 'callback':17 'callback-bas':16 'client':3,6,12,90 'communic':84 'current':27 'data':66 'differ':40 'e.g':47 'featur':44,75 'full':43 'full-featur':42 'generic':52 'generic-pool':51 'interfac':19 'javascript':88 'js':74 'lack':36,68 'last':30 'legaci':86 'librari':46 'log':61 'mainten':38 'minim':9 'modern':73 'modul':49 'net':48 'node.js':10 'offer':55 'pool':53 'project':87 'promis':69 'provid':14 'receiv':24,65 'request':22 'respons':25 'send':21 'sent':63 'simpl':57,79 'stabl':34 'style':82 'suitabl':76 'synchron':81 'synchronous-styl':80 'tcp':2,5,11,45,83,89 'tcp-client':1,4 'type':71 'typescript':70 'updat':31 'version':28 'wrapper':58","created_at":"2026-06-04T18:55:29.359641+00:00","updated_at":"2026-06-04T18:55:29.359641+00:00","problems":[{"fix":"Verify the server IP and port, increase timeout value, and ensure the server is reachable.","cause":"TCP connection timed out due to incorrect IP, port, or network issue.","error":"Error: connect ETIMEDOUT"},{"fix":"Use CommonJS require: const tcpClient = require('tcp-client').","cause":"The module import failed, likely due to using ESM import syntax (import tcpClient from ...).","error":"TypeError: Cannot read property 'request' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"tcp-client","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}