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

@skyring/tcp-transport

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skyring/tcp-transport

A TCP transport for skyring service

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

skyring-tcp-transport

A TCP based transport with connection pooling for Skyring.

Installation

$ npm install @skyring/tcp-transport --save

Usage

Skyring accepts an array property transports. Each entry can be a string or a named function. If given a string, skyring will pass it to require which must resolve to a named function

const Skyring = require('skyring')
const server = new Skyring({
  transports: ['@skyring/tcp-transport']
, seeds: ['localhost:3455']
})

server
  .load()
  .listen(3000)

Example Echo Server

// tcp echo server
'use strict'

let count = 0
const port = process.env.PORT || 5555
const net = require('net')
const server = net.createServer((socket) => {
  socket.on('data', (chunk) => {
    console.log(`${++count} ` + chunk)
  })
})

process.once('SIGINT', onSignal)
process.once('SIGTERM', onSignal)
server.listen(port, (err) => {
  if (err) {
    console.log(err)
    process.exitCode = 1
  }
  console.log('server listening')
})
function onSignal() {
  server.close()
}
$ curl -XPOST http://localhost:3000/timer -H 'Content-Type: application/json' -d '{
  "timeout":3000
, "data":"hello world!"
, "callback": {
    "transport": "tcp"
  , "method":"unused"
  , "uri": "tcp://0.0.0.0:5555"
  }
}'
>>> 1 hello world !

Keywords

FAQs

Package last updated on 17 Oct 2021

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