diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt index 9603a525..2876dfcb 100644 --- a/doc/zmq_setsockopt.txt +++ b/doc/zmq_setsockopt.txt @@ -190,7 +190,7 @@ ZMQ_IDENTITY: Set socket identity ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_IDENTITY' option shall set the identity of the specified 'socket' when connecting to a ROUTER socket. The identity should be from 1 to 255 -bytes long and MAY NOT start with binary zero. +bytes long and may contain any values. If two clients use the same identity when connecting to a ROUTER, the results shall depend on the ZMQ_ROUTER_HANDOVER option setting. If that diff --git a/src/options.cpp b/src/options.cpp index ddd36285..e569710b 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -89,11 +89,8 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, break; case ZMQ_IDENTITY: - // Empty identity is invalid as well as identity longer than - // 255 bytes. Identity starting with binary zero is invalid - // as these are used for auto-generated identities. - if (optvallen_ > 0 && optvallen_ < 256 - && *((const unsigned char *) optval_) != 0) { + // Identity is any binary string from 1 to 255 octets + if (optvallen_ > 0 && optvallen_ < 256) { identity_size = optvallen_; memcpy (identity, optval_, identity_size); return 0;