Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tcp-log-client

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcp-log-client

stream and write tcp-log-server entries

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
766
decreased by-7.71%
Maintainers
1
Weekly downloads
 
Created
Source

Stream and write tcp-log-server entries. Reconnect automatically.

var TCPLogClient = require('tcp-log-client')

var client = new TCPLogClient({
  // Use these options for `require('net').connect(options)`.
  server: {port: port},
  // Enable TCP keepalive. Enabled by default.
  keepAlive: true,
  // Disable the Nagle algorithm. Disabled by default.
  noDelay: true,
  // Start reading from entry index 1. 1 by default.
  from: 1,
  // Stop trying to reconnect and fail after 5 attempts.
  reconnect: {failAfter: 5}
})
  .on('error', function (error) {
    console.error(error)
  })
  .on('fail', function () {
    console.error('Failed to reconnect.')
  })
  .once('ready', function () {
    if (client.connected) {
      client.write({example: 'entry'}, function (error, index) {
        console.log('New entry index is %d', index)
        // Permanently disconnect and end `client.readStream`.
        client.destroy()
      })
    }
  })

// Readable stream of log entries.
// Entries added with `client.write()` will be streamed, too.
client.readStream.on('data', function (chunk) {
  console.log(chunk.index)
  console.log(chunk.entry)
})

See also:

Keywords

FAQs

Package last updated on 02 Jul 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc