🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

read-write-message

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-write-message

Read/write a length prefixed JSON message to a stream and send regular binary data afterwards. Useful for sending stream headers etc.

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

read-write-message

Read/write a length prefixed JSON message to a stream and send regular binary data afterwards. Useful for sending stream headers etc.

npm install read-write-message

Usage

var rw = require('read-write-message');
var net = require('net');

net.createServer(function(socket) {
	rw.read(socket, function(header) {
		console.log(header);
		socket.pipe(process.stdout);
	});
}).listen(10000, function() {
	var socket = net.connect(10000);
	rw.write(socket, {hello:'world'});
	socket.write('other stuff as well...');
});

The above example will print

{hello: 'world'}
other stuff as well...

License

MIT

Keywords

stream

FAQs

Package last updated on 18 Dec 2013

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