Questions tagged [nanomsg]

nanomsg is a socket library that provides several common communication patterns. It aims to make the networking layer fast, scalable, and easy to use.

was initiated by efforts from Martin Sústrik, the creator of ZeroMQ, nanomsg, and gets further evolved past version 1.1.2+ released in 2017/Q4

import nnpy
# ----------------------------------------# DEF SOCKET ARCHETYPE ACCESS-POINTS:
p1 = nnpy.Socket( nnpy.AF_SP, nnpy.PAIR )
p2 = nnpy.Socket( nnpy.AF_SP, nnpy.PAIR )

# ----------------------------------------# SET TRANSPORT CLASS(-es) TO BE USED:
p1.bind(    'inproc://pairExcellence' )   # p1.bind(    'ipc:///tmp/pair' )
p2.connect( 'inproc://pairExcellence' )   # p2.connect( 'ipc:///tmp/pair' )

# ----------------------------------------# USE THEM TO SEND MESSAGES:
p1.send( 'hello, p2' ); p1.send( 'I am p1' )

# ----------------------------------------# AND ENJOY THE AUTOMATED DETAILS:
print( "P2 RECV'd: {0:}".format( p2.recv() ) ); p2.send( 'nice to meet you' )
print( "P1 RECV'd: {0:}".format( p1.recv() ) )
print( "P2 RECV'd: {0:}".format( p2.recv() ) )

INTRO:

The concept still uses a word socket for naming a communication channel, yet it is rather a well abstracted socket, than a POSIX-compliant socket one may have been used to - let us view these abstracted sockets as rather a pre-wired behaviour archetype, that was encoded into their operations:

  • a PAIR - a simple archetype for one-to-one communication

  • a BUS - an archetype for a simple many-to-many communication

  • a REQREP - archetype that allows to build clusters of stateless services to process user requests

  • a PUBSUB - an archetype that distributes messages to large sets of interested subscribers

  • a PIPELINE - archetype aggregates messages from multiple sources and load balances them among many destinations

  • a SURVEY - archetype allows to query state of multiple applications in a single go


NOT A SOCKET AS A SOCKET?

To understand better the breadth of the potential setup and configuration options, one may first notice:

  1. The abstracted-socket access-point may be either "connected" ( using a call to nn_connect() ) towards another access-point present and ready at some remote infrastructure address or "bound" ( using nn_bind ) which instantiates such a service access-point for the former one.
  2. There may be multiple connects and binds on a single abstracted socket instance.
  3. There are certain socket configuration options that may be set or changed by programmer.

DOCUMENTATION:

While nanomsg borrows a lot from Martin Sústrik's work on ZeroMQ, there are principal differences and other language-specific details documented here.

80 questions
0
votes
0 answers

Clarification on the ephemeral port range in NNG

At https://nng.nanomsg.org/man/tip/nng_sockaddr_zt.5.html, the explanation of the sa_port argument reads: This field holds the port number used by the zt transport to distinguish different sockets. This value in native byte order. A zero value here…
landau
  • 5,636
  • 1
  • 22
  • 50
0
votes
0 answers

how to apply Nanomsg Protocol using Java NIO

I'm new the world of TCP / IP, Networking, Sockets etc.. during my internship I should replace the Nanomsg Library with java-only code. My supervisor has also sent me the following protocol and wants me to write a implement it:…
Ilyass
  • 1
  • 1
0
votes
0 answers

Efficient approach of sending data from a .NET based program to a C++ based OpenGL GUI

We're writing a visualization tool of complex 3D geometries of a existing 3D modelling software (A). After some initial experiments, we realized that the A does not have the API for all of our visualization purposes, and we decided to write our own…
X.Arthur
  • 277
  • 2
  • 13
0
votes
1 answer

nanomsg pub/sub with multiple subscribers using binary msg and topic name

how we can send msg from publisher to subscriber on different topics in one structure and how topics can be retrieved in subscriber. C/C++ code example
0
votes
2 answers

Problems with mangos - the nanomsg bus protocol provided by Golang package

I'd like to use nanomsg/nng as the communication basis of a fully distributed peer-to-peer multi-node network, to help construct the dynamic ability of topological discovery and maintenance. Now I get stuck in its Golang package mangos. The same…
xc wang
  • 318
  • 1
  • 3
  • 14
0
votes
1 answer

Does gRPC support zeromq or nanomsg?

According to the gRPC.io website I know gRPC supports http 1.x and 2.0 but what about other "transports" like zeromq or nanomsg?
Langley
  • 499
  • 6
  • 12
0
votes
0 answers

why is flatbuffers and nng no copy is slower that double copy

i am using flatbuffers and nng. using FB i am creating seralized buffers and adding it to nng msg. I wanted to eliminate this copying of FB to NNG. To achieve this i wrote a custom allocator as below. class CustomAllocator : public…
vk-code
  • 950
  • 12
  • 22
0
votes
2 answers

Nnanomsg bus routing support?

I have been using NNG (C++) - now I need to write a C# plugin to read the NNG NanoMSG messages. But I am moving from pub/sub to a bus/mesh protocol. e.g. https://nanomsg.org/gettingstarted/bus.html Does nnanomsg support that? What switches on the…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
0
votes
1 answer

How to design an asynchronous handling of both nanomsg socket and tty or Netlink?

How can I write a main loop (in C for Linux system) which blocks while waiting for messages from multiple sources such as a ) a nanomsg socket and serial port, or b ) a nanomsg socket and Netlink socket? Where to start? I think I could poll the…
IgorJ
  • 1
  • 3
0
votes
1 answer

ZeroMQ/NanoMsg pub/sub vs multicast

I want to implement data distribution application using zeromq or nanomsg or aeron.net or OpenDDS or OpenMAMA, I am little confused , which one is suitable as my requirement is to support 500 to 1000 users and each user can subscribe for atleast 100…
Zubair
  • 3
  • 3
0
votes
1 answer

Nanomsg multicast bandwidth issue

Can I have pure multicasting in pub/sub protocol of the nanomsg. As there can be N subscribers interested in a particular data for a single publisher, the same subscribed data is flowing in N different streams.If my bandwidth for a single stream is…
0
votes
1 answer

Nanomsg message encryption between communicating nodes

I am new to messaging world and started using Nanomsg library in my application. I want to know whether the messages are encrypted by default between the server and the client by the Nanomsg library. If not, how can I add encryption to secure the…
moosambi2020
  • 107
  • 3
0
votes
1 answer

After doing nn_send, the nn_socket will forbid to send the next piece of data immediately in a Req/Rep mode

I'm using nanomsg to transfer pieces of my data from Windows to CentOS. At the moment, I'm using Req/Rep mode. The CentOS will send a Req-request, and "Windows" will respond with a Rep to it. It looks alright. But the pieces of data I respond to…
norikoSD
  • 92
  • 9
0
votes
2 answers

Fails to npm install nanomsg

I try to install nanomsg on a linux machine so I do npm install nanomsg --python=python2.7 I use --python=python2.7 option, because I have two different versions of python. However that command fails with this kind of error message make: Entering…
nabroyan
  • 3,225
  • 6
  • 37
  • 56
0
votes
0 answers

Can I listening port in native code on Android?

I have built nanomsg for android, so I have native lib (.so). And I try bind a socket (with Nanomsg). I don't see any exceptions, but I can't connect to Socket. If I create SocketServer (not from native code, not from C, but with just Android API)…
Puzirki
  • 442
  • 5
  • 16