0.1.1 • Published 8 years ago

stream-url-node v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Node API adapters for stream-url (TCP)

stream-url marries streams and urls.

This package implements protocol adapters for all kinds of streams Node.js API provides access to.

  • TCP, tcp://address:port
  • filesystem sockets
  • UDP
  • HTTP
  • stdin/stdout

API user can start a server or a client connection using an ultra-compact universal interface of two methods: listen and connect.

// Server

var su = require('stream-url-node');

// start a WebSocket echo server
su.listen ('tcp://localhost:1234', function ready(err, server) {

    if (err) {
        console.error(err);
        return;
    }

    server.on('connection', function (stream) {

        stream.on('data', stream.write.bind(stream));

    })

});


// Client

var su = require('stream-url-ws');

su.connect('tcp://localhost:1234', function ready(err, stream) {

    stream.on ('data', function log (data) {
        console.log(''+data);
        stream.end();
    });

    stream.write('Hello world!');

});
0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago