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
2
votes
1 answer

Is it possible to connect to a nanomsg socket from a C# client?

I am experimenting with nanomsg. Is it possible to connect to a nanomsg socket from a client using .NET's Socket class or for that matter, any other socket library other than another nanomsg client? Are there any online tutorials and/or examples…
101010
  • 14,866
  • 30
  • 95
  • 172
2
votes
1 answer

Internal server based on nanomsg

I'm learning nanomsg and zeromq these days with Golang binding. I've tested with Req-Rep which can work, but is it a proper idea to use this mechanism to build reliable internal server for serving data under high concurrent requests (but from…
Jason Xu
  • 2,903
  • 5
  • 31
  • 54
1
vote
0 answers

Is parallel req/rep over one connection supported by nng (nanomsg-next-generation)?

I write a multithreaded application and would like to send and receive messages (RPC like) in parallel. Both client and server should be able to send requests. Is this possible with nng? With only one connection, or do I need to set up two…
lxndr
  • 85
  • 4
1
vote
0 answers

Nanomsg gives signal 6 abort during fetching from couchbase

I am getting a signal 6 error when i am trying to fetch data from couchbase, this occurs at erratic intervals. I am using version 1.1 and from the code i can see if poll returns value less than 0, errno_assert is being triggered which crashes the…
1
vote
1 answer

Nanomsg error not reported for nn_recv when socket is unbinded

I have created a receiving socket, using nanomsg library and trying to nn_recv() a message as code below shows : recv_bytes = nn_recv ( socket_id, &buf, NN_MSG, 0 ); when the recv_bytes was < 0, I do following : if ( recv_bytes <= 0) { …
Stu
  • 13
  • 3
1
vote
1 answer

nng to pynng pub/sub. No messages recieved by client

I have the following server (C++): #include #include #include #include #include #include #include void fatal(const char *func, int rv) { …
Michael Hansen
  • 237
  • 2
  • 8
1
vote
1 answer

nng to pynng communication is not working

I am trying to make a c-program server that publishes images via nng, and a python client via pynng that subscribes to the images. For some reason i cannot connect these 2 parts and I dont know why. C/C++-program compiles and runs fine and so does…
Michael Hansen
  • 237
  • 2
  • 8
1
vote
1 answer

Nanomsg non-blocking bidirectional socket with multi-threaded application

I'm using Nanomsg to do IPC in my system using C++. I want to create a background thread to handle the message both send and recv. I use pair paradigm and I use nn_poll to check if the socket fd is writable or readable, if readable then read; if…
Tony Lin
  • 765
  • 3
  • 15
  • 35
1
vote
0 answers

Where are nanomsg nng libraries installed

I am new to nanomsg and cmake. I installed the nanomsg using the documentation $ mkdir build $ cd build $ cmake -G Ninja .. $ ninja $ ninja test $ ninja install I am not sure where are the packages installed. I see the headers in /usr/include…
1
vote
1 answer

Example of a bus using nngcat command line tool

nngcat (nng's command line tool) allows one to use the --bus flag. I want to send data from A1 process to A2 and A3 processes using the "--bus" flag of nngcat. (I know pub/sub and req/rep can also be used for that; the tool works wonderful with…
1
vote
1 answer

QSocketNotifier vs nanomsg

Is it possible to use QSocketNotifier for nanomsg socket in order to do something if any data is received? I tried to use this code, but nothing happens when I run nanocat --req --connect ipc:///tmp/node0.ipc --data pong --format ascii . I don't…
arsonist
  • 175
  • 1
  • 11
1
vote
1 answer

Link Errors for NanoMsg with VS2017

I am trying to build a nanomsg next gen (https://github.com/nanomsg/nng) on a windows box. I am using VS2017. The CMAKE worked like a charm. I am getting link errors. I have verifed that the nng.lib file is located…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
1
vote
2 answers

how to specify tcp protocol for "multicast" tcp in nanomsg

I have read: Nanomsg multicast bandwidth issue But I don't need true multicast IP (e.g. 239.0.0.0:3000) I also have a very light load. So I am not that concerned about backpressure. Yes, I could use the bus paradigm. But say I want to test first…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
1
vote
2 answers

Setting up socket timeout in nanomsg python

I am having trouble setting the timeout properly on nanomsg python in the PUSH/PULL schema. I use the set socket option function and passing in a ctype object. Both set_sock_options return a success. Am I missing something? The sockets work to…
teafellow
  • 35
  • 6
1
vote
0 answers

Resolving dependencies in Rust 32 bit cross-compilation

I'm working on a project that uses the nanomsg crate. The crate depends on the nanomsg library itself, which is a native library. So far so good. The problem comes when I cross compile the project to target the raspberry pi using the following…
Dash83
  • 1,357
  • 2
  • 17
  • 31