Code Monkey home page Code Monkey logo

nanomsg.node's Introduction

nanomsg.node: nanomsg node.js bindings


License: Beerware

example usage:


var nn = require('nanomsg.node')
, pub = nn.socket(nn.AF_SP, nn.NN_PUB)
, sub = nn.socket(nn.AF_SP, nn.NN_SUB);

nn.bind(pub, "tcp://127.0.0.1:7788");
nn.connect(sub, "tcp://127.0.0.1:7788");
nn.usleep(4000); // 4 ms

nn.send(pub, "Hello from nanomsg!");

console.log("received: " + nn.recv(sub));

Functions:


nn.sleep(seconds): sleep in seconds
nn.usleep(microseconds): sleep in microseconds(1 second = 1000000 microseconds)
nn.socket(sp_type, sock_type): get socket
nn.close(socket): close socket
nn.bind(socket, address): bind to address
nn.connect(socket, address): connect to address
nn.send(socket, message): send message to socket(message is binary safe)
nn.recv(socket): recv message from socket(return binary safe message string)
nn.errno(): get errno
nn.strerror(errno): get error string
nn.setsockopt(socket, level, option, optval): set socket option(all arguments must be integer)
nn.getsockopt(socket, level, option): get socket option(all arguments must be integer)

Constants:


// SP address families.
AF_SP, AF_SP_RAW

// Socket option levels: Negative numbers are reserved for transports,
// positive for socket types.
NN_SOL_SOCKET

// Generic socket options (NN_SOL_SOCKET level).
NN_LINGER, NN_SNDBUF, NN_RCVBUF, NN_SNDTIMEO
NN_RCVTIMEO, NN_RECONNECT_IVL, NN_RECONNECT_IVL_MAX
NN_SNDPRIO, NN_SNDFD, NN_RCVFD, NN_DOMAIN, NN_PROTOCOL
NN_IPV4ONLY

// Send/recv options.
NN_DONTWAIT

// Socket types
NN_REQ, NN_REP
NN_PAIR
NN_PUSH, NN_PULL
NN_PUB, NN_SUB
NN_BUS

nanomsg.node's People

Contributors

fatihky avatar

Watchers

 avatar

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.