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

request-stream

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-stream

json request-response over a stream

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
332
35.51%
Maintainers
1
Weekly downloads
 
Created
Source

request-stream

Send json request and responses over a stream

npm install request-stream

Lets try to setup a simple server

var rs = require('request-stream');
var net = require('net');

net.createServer(function(socket) {
	var r = rs();

	socket.pipe(r).pipe(socket);

	r.on('request', function(request, respond) {
		respond(null, {echo:request});
	});
}).listen(9000);

Since the server is a tcp server we just need to create a tcp socket and pipe our request to that.

var socket = net.connect(9000);
var r = rs();

socket.pipe(r).pipe(socket);

r.request('echo me please', function(err, reply) {
	console.log(err, reply);
});

Since r is just a stream we can pipe it to any kind of transport (even WebSockets using shoe).

Keywords

stream

FAQs

Package last updated on 18 Nov 2012

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