Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 every connection accept, am expecting some thing like that in nanomsg.

In below link am trying to use - Pair (Two Way Radio)

http://tim.dysinger.net/posts/2013-09-16-getting-started-with-nanomsg.html

like image 744
rameshrgtvl Avatar asked Oct 20 '22 23:10

rameshrgtvl


1 Answers

I don't think you can by default.

Messages come in, and whenever a message comes in, you process it. There's no additional data on which client connected, or where the message came from.

Thus, my suggestion would be to let every client identify itself by a UUID at the start of every message, or wrap the messages in a JSON like format of which one key is used by the client to identify itself.

like image 180
Willem Mulder Avatar answered Oct 23 '22 04:10

Willem Mulder