@anzerr/net.socket
TypeScript icon, indicating that this package has built-in type declarations

1.0.21 • Public • Published

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()));
	});
});

Readme

Keywords

Package Sidebar

Install

npm i @anzerr/net.socket

Weekly Downloads

107

Version

1.0.21

License

MIT

Unpacked Size

8.87 kB

Total Files

10

Last publish

Collaborators

  • anzerr