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
1
vote
1 answer

Having trouble accessing a global socket from within a function

I am having a trouble calling the .send() function of a socket, that was declared at the global level. from nanomsg import Socket, PAIR, PUB s2 = Socket(PAIR) s2.connect('tcp://127.0.0.1:49234') s2.send(b'connect') def myfunc(): global s2 …
1
vote
1 answer

How to properly handle an "Assertion Failed" message

I'm using nanomsg to send / receive data between multiple components. Sometimes when I publish some data to another component I get an error: "Assertion failed: ...". I'm not too familiar with Assertion (this is my first time encountering…
Roka545
  • 3,404
  • 20
  • 62
  • 106
1
vote
1 answer

Subscriber/receive data from publisher using nanomsg.

I'm using the C# data binding for nanomsg. I have an external program that is sending Google Protocol Buffer messages on the url ipc://report_data and my subscriber connects to that same exact url. So, I would expect my subscriber to be able to…
Roka545
  • 3,404
  • 20
  • 62
  • 106
1
vote
0 answers

A performance test doesn't work with nanomsg (bus)

I'd like to use nanomsg as bus-system. So I tried to code a performance test and testing it by using two PCs. At first I wrote an server, which connects to the other server: #include #include #include…
clausismus
  • 165
  • 1
  • 9
1
vote
1 answer

Which type of socket to use in nanomsg for TCP

I have downloaded the nanomsg library and I know it supports TCP sockets. I am trying to make a simple TCP server in C with it, but it has so many different type of sockets I don't know which one is right for simply making a TCP server. There is…
ModerateCarrot
  • 289
  • 1
  • 2
  • 12
1
vote
0 answers

weird situation for nanomsg and linux

It's very strange. I write a message distribute server upon nanomsg. But after some time,when i restart the server, i failed because the listening port has been used. Here is the situation: [root@vsmHost12 src]# lsof -n -i:3333 COMMAND PID USER FD…
taolinke
  • 33
  • 6
1
vote
1 answer

Want to implement nanomsg in android using its java binding jnanomsg getting java.lang.ExceptionInInitializerError

I am trying to implement nanomsg in android and i got java bindings from this link : http://niwinz.github.io/jnanomsg/ after this dependency compile 'jnanomsg:jnanomsg:0.4.3' . It was returning me this sun/jna/libjnidispatch.so was not found. After…
Rajesh N
  • 35
  • 6
1
vote
1 answer

Building nanomsg for Android

I have nanomsg and Android.mk from here. I try to build it for Android with Android NDK. And I have error: [armeabi] Compile thumb : nano <= usock.c In file included from…
Puzirki
  • 442
  • 5
  • 16
1
vote
0 answers

C - MySQL loses connection during query when application establishes a separate tcp connection

I am using MySQL in tandem with nanomsg in my C application. nanomsg is creating some tcp connections to remote servers, while MySQL is connecting to a localhost database. I am porting from SQLite, and don't have as much experience with MySQL, so…
Matthew Darnell
  • 1,315
  • 2
  • 12
  • 24
1
vote
1 answer

Is it possible to register a listener to network activity in nanomsg?

I'm using nanomsg to handle my network coding (and it's very good btw!), but I am having trouble figuring out if there is a way to get notified when data is available to be received. The only way I can see is to continuously poll a socket for data…
Cthutu
  • 8,713
  • 7
  • 33
  • 49
1
vote
2 answers

Is nanomsg or ZeroMQ appropriate for scaling number of client connections?

I need to build a sort of Instant Messaging system. From my brief exploration ZeroMQ and nanomsg are aimed at server-server communication in a backend distributed system, rather than managing +100K simultaneous end user client connections. Is that…
user1055568
  • 1,349
  • 13
  • 21
1
vote
1 answer

surveyor respondent pattern in nanomsg in python

I am trying to write a surveyor respondent pattern. But it throws the error: nanomsg.NanoMsgAPIError: Operation cannot be performed in this state from nanomsg import * s1 = Socket(SURVEYOR) s1.bind('ipc://bob') s1.send(b'hello…
Davoud Taghawi-Nejad
  • 16,142
  • 12
  • 62
  • 82
1
vote
0 answers

Using nanomsg in Kernel-Space

I am looking into the feasibility of using nanomsg within kernel-space. The idea is to have a kernel process/thread send and receive messages across a nanomsg socket to local (user-space) and/or remote nanomsg sockets. I imagine this will not work…
Alexander
  • 415
  • 3
  • 10
0
votes
0 answers

Issue with POST Request Header and Payload Being Segmented into Two Frames

Problem Description: When using the nanomsg library to send a POST request, the header and payload of the request are segmented into two frames instead of being sent as a single packet. According to the HTTP/1.1 protocol specification, a POST…
linaki
  • 13
  • 3
0
votes
1 answer

Why would nng_dial ever hang?

I'm running into a perplexing issue with nng (EDIT and gtest) in c++. The first code block below is a simple program which creates a publisher and continuously sends messages. The second code block below is a simple program which successfully…