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

Add a dll/so to a python built distribution

I've compiled the python wrapper of nanomsg and I want to create a python installer for the package.The package can be created by running python setup.py bdist --format=wininst However I would like nanomsg.dll/nanomsg.so to be included in the…
shluvme
  • 713
  • 7
  • 24
11
votes
3 answers

Difference between ZeroMQ and IPC

Q1: What exactly is the difference between using ZeroMQ to send messages to child processes, as compared to the default inter process communication explained here? Q2: For direct process to child communication, which would be more appropriate?…
NiCk Newman
  • 1,716
  • 7
  • 23
  • 48
8
votes
1 answer

CMake Error : execution of make failed on Windows

I am getting errors when trying to build nanomsg project in Windows 7: cmake .. -- Building for: NMake Makefiles -- The C compiler identification is GNU 4.7.1 -- Check for working C compiler: C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe CMake…
Mouin
  • 1,025
  • 4
  • 19
  • 33
7
votes
2 answers

Building a CMake library within a Bazel project

I've written a module on top of a private fork off of TensorFlow that uses nanomsg. For my local development server, I used cmake install to install nanomsg (to /usr/local) and accessed the header files from their installed location. The project…
Jedi
  • 3,088
  • 2
  • 28
  • 47
7
votes
2 answers

ZeroMQ / 0mq or nanomsg bindings to Kafka?

In Fred Georges talk about microservice architectures, he mentions using Kafka as a high speed bus (he refers to as the rapids) and connecting multiple 0mq instances (referred to as rivers) to it. A slide of this can be seen here. Can anyone share…
user1074891
  • 279
  • 3
  • 14
6
votes
2 answers

libc.h: No such file or directory when compiling nanomsg pipeline sample

Trying to get a simple nanomsg file running, starting with the first one here: https://github.com/dysinger/nanomsg-examples Installed nanomsg to /usr/local/lib/nanomsg-0.2-alpha. Ran sudo ./configure, sudo make check, sudo make install and sudo…
jcollum
  • 43,623
  • 55
  • 191
  • 321
5
votes
1 answer

How to differentiate between each client connections in nanomsg socket library

Am using nanomsg library with int sock = nn_socket (AF_SP, NN_PAIR); assert (nn_bind (sock, url) >= 0); Now I want to know how to differentiate each connection in server if client connects. In Regular Linux TCP Socket, we will get new socket fd on…
rameshrgtvl
  • 243
  • 2
  • 16
4
votes
1 answer

pynng: how to setup, and keep using, multiple Contexts on a REP0 socket

I'm working on a "server" thread, which takes care of some IO calls for a bunch of "clients". The communication is done using pynng v0.5.0, the server has its own asyncio loop. Each client "registers" by sending a first request, and then loops…
Artesim
  • 79
  • 8
4
votes
1 answer

How to use nanomsg survey architecture without while loop?

I was going through nanomsg usage for IPC and wanted to use SURVEY-archetype architecture described here.In this, processes run as client and server and exchange data. Now server has following code (also listed in the provided link): int server…
Aman
  • 696
  • 1
  • 8
  • 26
4
votes
2 answers

PUB/SUB can I .connect() before I .bind()?

I'm using a PUB/SUB design and my question is: Can I .bind() to a port after another socket has .connect()-ed to it, or should I .bind() before another socket tries to .connect() to the same address? In other words: Does the order of .bind() and…
barakcaf
  • 1,294
  • 2
  • 16
  • 27
3
votes
1 answer

Why would nanomsg hang?

I just started doing nnanomsg programming with C#. For a simplistic client / server example, I'm starting with the following example where a client connects with a server to get the next number. For now, the example is for localhost, except I have…
Bill Early
  • 131
  • 1
  • 8
3
votes
0 answers

Trying to pass a structure by pointer into C library from Python

Can't figure out how to pass a structure by pointer to a C function from Python. Here is what I have (it's a part of bigger effort of implementing nn_recvmsg for nanomsg-python project): ... msgHdr = NN_MSGHDR(iovecList) pointer_type =…
peetonn
  • 2,942
  • 4
  • 32
  • 49
3
votes
1 answer

How to setup a Pub/Sub in nanomsg between a C and Python sides?

I'm trying to learn the nanomsg library. I'm using the code examples of both versions C and Python. I'm trying to subscribe to the C service with a Python script, but nothing is happening. Here's both of my code : Python subscriber from __future__…
matcha-tea
  • 99
  • 10
3
votes
1 answer

Example of nanomsg crate does not work

I tried the Rust nanomsg pubsub example, but it does not work. I did each of these operations in separate console windows: cargo run --example pubsub -- device hoge It shows Subscribed to '[104, 111, 103, 101]'. Device is ready. cargo run…
3
votes
0 answers

Nanomsg import error

I'm having problems using NanoMsg. I was using default sockets before but then someone pointed out that this was a bad idea. So I searched to get a better package and found NanoMsg. When I tried importing I got this error: Python 3.5.2…
jotjern
  • 460
  • 5
  • 18
1
2 3 4 5 6