npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

turbo-net-clusterable

v1.4.1

Published

Low level TCP library

Downloads

2

Readme

This is a fork of turbo-net that enables node cluster support

turbo-net-clusterable

Low level TCP library for Node.js

npm install turbo-net

build status Build status

Usage

const turbo = require('turbo-net')

// Echo server that allocates constant memory

const server = turbo.createServer(function (socket) {
  socket.read(Buffer.alloc(32 * 1024), function onread (err, buf, read) {
    if (err) throw err
    socket.write(buf, read, function (err) {
      if (err) throw err
      socket.read(buf, onread)
    })
  })
})

server.listen(8080, function () {
  const socket = turbo.connect(8080)

  socket.read(Buffer.alloc(32), function (err, buf, read) {
    if (err) throw err
    console.log(buf.toString('utf-8', 0, read))
  })
  socket.write(Buffer.from('hello world\n'))
})

Performance

Running the echo server examples in ./examples I get the following throughput on my laptop

  • echo-classic: 1.3GB/s at ~100MB of ram
  • echo-turbo: 3.4GB/s at ~35MB of ram

API

server = turbo.createServer([options], [onsocket])

Create a new TCP server. Options include:

{
  allowHalfOpen: false, // set to true to allow half open TCP connections
  reusePort: true // Disable if you don't want SO_REUSEPORT to be set (SO_REUSEADDR on windows)
}

server.on('connection', connection)

Emitted when a new connection is established.

server.on('listening')

Emitted when the server is listening.

server.connections

Unordered array containing the current active connections

server.listen(port, [address], [onlistening])

Listen on a port.

server.address()

Similar to net.Server.address. Useful if you are listening on port 0, to find out which port was picked.

server.close([onclose])

Close the server.

connection = turbo.connect(port, host, [options])

Connect to a TCP server. Options include:

{
  allowHalfOpen: false // set to true to allow half open TCP connections
}

connection.on('connect')

Emitted when a client connection is fully connected.

connection.on('error', err)

Emitted when a client fails to connect.

connection.on('close')

Emitted a connection is fully closed. No other events will be emitted after.

connection.on('finish')

Emitted when the writable side is fully closed.

connection.on('end')

Emitted when the readable side is fully closed.

connection.close([callback])

Closes the connection.

connection.read(buffer, callback)

Read data from the connection. Data will be read into the buffer you pass.

The callback is called with callback(err, buffer, bytesRead).

If bytesRead is 0, then the readable side of the connection has ended.

connection.write(buffer, [length], [callback])

Write data to the connection. Optionally you specify how many bytes in the buffer you want to write.

The callback is called with callback(err, buffer, length).

connection.writev(buffers, [lengths], [callback])

Write more than one buffer at once. Optionally you can specify how many bytes in each buffer you want to write.

The callback is called with callback(err, buffers, lengths).

connection.end([callback])

End the writable side of the connection.

License

MIT