GithubHelp home page GithubHelp logo

node-datagram-stream's Introduction

datagram-stream

Build Status

A streaming UDP module with broadcast, multicast and unicast options.

install

npm install datagram-stream

usage

multicast

var udp = require('datagram-stream');

var stream = udp({
    address     : '0.0.0.0'   //address to bind to
    , multicast : '239.5.5.5' //multicast ip address to send to and listen on
    , port      : 5555        //udp port to send to
    , bindingPort : 5556      //udp port to listen on. Default: port
    , reuseAddr : true        //boolean: allow multiple processes to bind to the
                              //         same address and port. Default: true
    , loopback  : true        //boolean: whether or not to receive sent datagrams
                              //         on the loopback device. Only applies to
                              //         multicast. Default: false
});

//pipe whatever is received to stdout
stream.pipe(process.stdout);

//pipe whatever is received on stdin over udp
process.stdin.pipe(stream);

broadcast

var udp = require('datagram-stream');

var stream = udp({
    address     : '0.0.0.0'         //address to bind to
    , broadcast : '255.255.255.255' //broadcast ip address to send to
    , port      : 5555              //udp port to send to
    , bindingPort : 5556            //udp port to listen on. Default: port
    , reuseAddr : true              //boolean: allow multiple processes to bind to the
                                    //         same address and port. Default: true
 });

//pipe whatever is received to stdout
stream.pipe(process.stdout);

//pipe whatever is received on stdin over udp
process.stdin.pipe(stream);

unicast

var udp = require('datagram-stream');

var stream = udp({
    address     : '0.0.0.0'   //address to bind to
    , unicast   : '127.0.0.1' //unicast ip address to send to
    , port      : 5555        //udp port to send to
    , bindingPort : 5556      //udp port to listen on. Default: port
    , reuseAddr : true        //boolean: allow multiple processes to bind to the
                              //         same address and port. Default: true
 });

//pipe whatever is received to stdout
stream.pipe(process.stdout);

//pipe whatever is received on stdin over udp
process.stdin.pipe(stream);

acknowledgments

I used @dominictarr's broadcast-stream as a guide for how to implement the stream.

license

MIT

node-datagram-stream's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-datagram-stream's Issues

Multicast does not bind to a specific interface.

Listening to multicast does not join a specific interface when calling socket.addMembership(multicast); The datagram documents for addMembership say:

If the multicastInterface argument is not specified, the operating system will choose one interface and will add membership to it. To add membership to every available interface, call addMembership multiple times, once per interface.

My expectation for the options provided is the multicast option is the multicast address to listen to, and the address option is the interface to receive it on. That requires changing the bind and addMembership lines like seen here. vidterra@a43032d

This is similar to the issue described here nodejs/node#19954

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.