You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the definition of s_set_id (zmq::socket_t &) in zhelpers.hpp the random function (in within macro) is not seeded, hence, if called from the same host generates always the same id.
So the following code if called from different processes (or threads) on the same host prints always the same id:
For the same reason, we can not put the call to srand in s_set_id(Someone may call s_set_id from multiple threads or in a for loop). Instead, we should call srand ourselves at the beginning of the program. Just like most of the examples do(rtdealer.c#L59, for instance).
In the definition of
s_set_id (zmq::socket_t &)
inzhelpers.hpp
the random function (inwithin
macro) is not seeded, hence, if called from the same host generates always the same id.So the following code if called from different processes (or threads) on the same host prints always the same id:
Suggested fix: add
srand(time(NULL))
at the beginning ofs_set_id (zmq::socket_t &)
body inC++/examples/zhelpers.hpp
The text was updated successfully, but these errors were encountered: