Socket
Socket
Sign inDemoInstall

@anzerr/net.socket

Package Overview
Dependencies
1
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @anzerr/net.socket

Server and client for tcp sockets


Version published
Weekly downloads
130
increased by22.64%
Maintainers
1
Install size
12.4 kB
Created
Weekly downloads
 

Readme

Source

Intro

GitHub Actions status | linter GitHub Actions status | publish GitHub Actions status | test

Light wrapper around nodes net.socket

Install
npm install --save git+https://github.com/anzerr/net.socket.git
npm install --save @anzerr/net.socket

Example

Server

const net = require('net.socket');
let server = new net.Server('localhost:596');
server.on('message', (res) => {
	let client = res.client, payload = JSON.parse(res.payload.toString());
	console.log('Server recieve', client.id(), payload);
	client.send(JSON.stringify({pong: payload}));
});

Client

const net = require('net.socket');
let c = new net.Client('localhost:596');
c.on('connect', () => {
	console.log('client connected');
	c.send(JSON.stringify({test: 'cat10'}));
	c.on('message', (res) => {
		console.log('Client message', JSON.parse(res.toString()));
	});
});

Keywords

FAQs

Last updated on 21 Jan 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc