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 identity[256]"

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
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to