New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bsp

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bsp

Basic Socket Protocol

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-61.54%
Maintainers
1
Weekly downloads
 
Created
Source

Basic Socket Protocol

install

npm i bsp

Usage

import * as net from "net";
import { send, receive } from "bsp";

var server = net.createServer(socket => {
    let temp = []; // a container to store incomplete data.

    socket.on("data", buf => {
        for (let msg of receive(buf, temp)) {
            // the first message would be 'Hello, World!'
        }
    });
});

server.listen(8000, () => {
    var socket = net.createConnection(8000);

    socket.on("connect", () => {
        socket.write(send("Hello, World!"));
    });
});

API

  • send(...data: any[]): Buffer
  • receive(buf: Buffer, temp: any[]): IterableIterator<any>

Notice

Due to performance and compatibility considerations, this module (since version 0.2) uses JSON to transfer data instead.

API change in v0.3, passing multiple arguments into send() now acts exactly the same as calling send() multiple times.

Keywords

FAQs

Package last updated on 11 Sep 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