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
3
votes
2 answers

What is a good ZeroMQ / nanomsg architecture for a server that sends data to clients that can connect / disconnect?

I am trying to create a network architecture which has a single server and multiple clients. The clients can connect and disconnect at any time so they need to announce their existence or shut-down to the server. The server must be able to send…
Cthutu
  • 8,713
  • 7
  • 33
  • 49
3
votes
1 answer

Thread-friendly main loop for GTK and nanomsg

How can I write a main loop which blocks while waiting for messages from multiple sources? As I understand it, the preferred way of writing an event-processing loop is to have it block while waiting for events. However, how can blocking be handled…
dhardy
  • 11,175
  • 7
  • 38
  • 46
3
votes
1 answer

Socket connection between C (nanomsg) and Python (non-nanomsg)

I created a socket server in C (using nanomsg) which shall communicate with a Python script (using standard 'Socket' implementation) via TCP: C-Code (without error handling): #include #include ... char…
linksfate
  • 101
  • 1
  • 8
3
votes
1 answer

Nanomsg TCP Handshake

I also posted this in the Arduino section, but this problem is probably caused more by my ignorance of nanomsg and connections in general rather than an Arduino problem. I am attempting to communicate with a server that is using nanomsg to…
Eric D
  • 101
  • 1
  • 5
3
votes
1 answer

How to get nanomsg to automatically reconnect reliably?

I am having problems handling reconnects when the server briefly goes offline or totally offline and then comes back up. I can't get my clients to automatically reconnect. Also, there is no property anywhere where I can see the status of the socket…
101010
  • 14,866
  • 30
  • 95
  • 172
3
votes
1 answer

cmake error using the mingw-w64-x86_64 gcc toolchain under Windows 7 : "this program has been built without plugin support"

I have a setup with Windows 7, MSYS2, Mingw-w64-x86_64 gcc toolchain, CMake, and I am trying to build the nanomsg library. Here is what I obtain : $ cmake --debug-trycompile -DCMAKE_TOOLCHAIN_FILE=../toolchain_i686-pc-mingw32.cmake…
lalebarde
  • 1,684
  • 1
  • 21
  • 36
2
votes
0 answers

Reason for losing messeges over NNG sockets in raw mode

Some context to my problem: I need to establish an inter-process communication using C++ and sockets and I picked NNG library for that along with nngpp c++ wrapper. I need to use push/pull protocol so no contexts handling is available to me. I wrote…
2
votes
1 answer

node-nanomsg - subscriber does not receive messages

I have two .js files - pub.js for publication and sub.js for subscription. These files are actually a 'split' version of the example shown on node-nanomsg GitHub site. The pub.js writes to tcp://127.0.0.1:7789 and sub.js reads from the same. I start…
cogitoergosum
  • 2,309
  • 4
  • 38
  • 62
2
votes
2 answers

multiple publishers & subscribers in nanomsg (nng)

How does one setup multiple publishers & subscribers with a TCP transport. I suspect that you don't do automatic mesh/bus creation. So one needs a unique IP bind point for each publishers, right? They just have the subscribers connect to each…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
2
votes
2 answers

NanoMsg (NNG) & FlatBuffers the correct fit for this project?

Shout out if there is something better we should consider: I am looking for a very quick and simple way to get several programs (e.g. 5) - each running on separate nodes on a private OpenStack cloud to talk to each other. Packets will be short C++…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
2
votes
1 answer

Is there an IP multicasting possible in nanomsg?

How can I achieve an IP Multicasting in nanomsg? I know that in ZeroMQ messaging, the IP Multicasting is achieved through a Pragmatic General Multicast ( PGM ) protocol. Is there any way in nanomsg to also achieve the IP Multicasting?
2
votes
1 answer

The type initializer "Class" threw an exception.LoadLibrary failed

I have a service that tries to load a DLL. My service works fine on my development laptop, but when trying it two other laptops I get the following exception: The type initializer for "NanoProtoApi.Interop" threw an exception. --->System.Exception:…
Roka545
  • 3,404
  • 20
  • 62
  • 106
2
votes
1 answer

'nanomsg/nn.h' file not found on MAC

I want to install nn with LuaRocks on macOS. But when running sudo luarocks install nn //I use sudo because otherwise I don't have permission to install I am getting the error lnn.c:4:9: fatal error: 'nanomsg/nn.h' file not found include …
user2212461
  • 3,105
  • 8
  • 49
  • 87
2
votes
2 answers

Does nanomsg have the concept of 'frames' as zeromq?

I have been using zeromq for some time and use multipart message extensively. In C++, I use zmq_sendiov/zmq_recviov to send/recv multipart message. The benefit is I can put each message 'frame' in one iovec, and use the call to send/recv in one…
Ralph Zhang
  • 5,015
  • 5
  • 30
  • 40
2
votes
0 answers

Bad readable state with nanomsg surveyor socket

I am using the SURVEY scalability protocol with nanomsg in Python. I have a bunch of respondent sockets, I connect a surveyor to them in a loop; then, I wait for surveyor.send_fd to be readable. I assume it is connected to at least one…
mguijarr
  • 7,641
  • 6
  • 45
  • 72