[zeromq-dev] [zmqpp] Identity blob

Laurent Alebarde l.alebarde at free.fr
Sat Jan 11 09:33:10 CET 2014

The function prototype is :

int zmq_setsockopt (void *socket, int option_name, const void 
*option_value, size_t option_len);

So you can use anything. Inside options.cpp, it is typecasted to 
"unsigned char*", and the attribute it is copied to is: "unsigned char 

If you want to use an integer, just do:

int myID = 12345;
int rc = zmq_setsockopt (p_socket, ZMQ_IDENTITY, &myID, sizeof(int));

For zmqpp, if the argument is a string, I would suggest to patch the 
code with a new method that would use the original libzmq arguments. 
Typecasting an int to a string won't work because you may have zeros. 
Conversion with something like itoa is possible, but personnaly, I don't 
like it. It implies convertions in many places.

Le 10/01/2014 23:10, Lindley French a écrit :
> I notice that the only valid data type for the identity socket option 
> is a string. In libzmq, my understanding is that identity is a binary 
> blob. What if I want to use an integer for identity, or a UUID? I can, 
> of course, convert these types to strings, but this isn't necessarily 
> the best network encoding.
> Opinions: Should other types be usable in zmqpp for the identity 
> socket option?
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140111/e407373b/attachment.htm>

More information about the zeromq-dev mailing list