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

msgpack-sock

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msgpack-sock

Msgpack wrap for net.Socket and tls.TLSSocket

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

MsgpackSock

Msgpack wrap for net.Socket and tls.TLSSocket

Installation

npm install --save msgpack-sock

Using

const net = require('net');
const MsgpackSock = require('msgpack-sock');

//echo server
net.createServer(MsgpackSock.createConnectionHandler(socket => {
    socket.on('message', msg => socket.send(msg));
})).listen(3000);

//client
const socket = MsgpackSock.wrap(net.createConnection(3000));
socket.on('message', msg => console.log(msg));
socket.send('string');
socket.send(true);
socket.send({
    str: 'string',
    arrOfNumbers: [1 ,2 , 3],
    bool: false,
    buffer: Buffer.from('buffer', 'utf-8')
});

Api

Static methods

  • MsgpackSock.createConnectionHandler (callback: function(socket: MsgpackSock), codec: ?msgpackLite.Codec): function(socket: net.Socket | tls.TLSSocket)
  • MsgpackSock.wrap (socket: net.Socket | tls.TLSSocket, codec: ?msgpackLite.Codec): MsgpackSock
  • MsgpackSock.createCodec - see https://www.npmjs.com/package/msgpack-lite#custom-extension-types-codecs
  • MsgpackSock.encode - see https://www.npmjs.com/package/msgpack-lite#encoding-and-decoding-messagepack
  • MsgpackSock.decode - see https://www.npmjs.com/package/msgpack-lite#encoding-and-decoding-messagepack

Events

  • message (msg: any) - New message received
  • close () - Socket closed
  • error (err: Error) - Received error
  • connect - transfered from net.Socket
  • drain - transfered from net.Socket
  • lookup - transfered from net.Socket
  • timeout - transfered from net.Socket
  • OCSPResponse - transfered from tls.TLSSocket
  • secureConnect - transfered from tls.TLSSocket

Methods

  • send (msg: any) - Send message
  • close () - Close connection
  • address - from net.Socket
  • setKeepAlive - from net.Socket
  • setNoDelay - from net.Socket
  • setTimeout - from net.Socket
  • ref - from net.Socket
  • unref - from net.Socket
  • getCipher = from tls.TLSSocket
  • getEphemeralKeyInfo = from tls.TLSSocket
  • getPeerCertificate = from tls.TLSSocket
  • getProtocol = from tls.TLSSocket
  • getSession = from tls.TLSSocket
  • getTLSTicket = from tls.TLSSocket
  • renegotiate = from tls.TLSSocket
  • setMaxSendFragment = from tls.TLSSocket

Keywords

FAQs

Package last updated on 11 May 2017

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