Closed detly closed 3 years ago
Please excuse me, this is totally unrelated to your library and 100% due to my misuse of CZMQ. My sending code (the push socket) was closing the socket too quickly. The default "linger" for ZeroMQ sockets is -1
for the low level API, but 0
for CZMQ. Setting it to -1
in my C code makes it all work fine.
Using:
I have found that a small example program with a pull socket only receives maybe 1 out of every 50 messages I send via a push socket, using IPC.
In one terminal, I'll compile the C example below and run:
Hold down ctrl+c to kill it after you're done.
In another terminal, I'll do
cargo run
and see:That first loop over the C program can easily run a couple of hundred times, and I might only see a couple of messages printed by the Rust code.
The Rust code:
The C (CZMQ) code:
I have tried it with IPC sockets, both "abstract" sockets (ie. not appearing in the filesystem, see the
@
afteripc://
) and non-abstract, as well as TCP. It goes the same way.Am I using the library wrong here? I don't have another system to try it on to see if it's an OS thing, and I'm relatively new to Rust so maybe I've made a mistake, but the fact that it works sometimes has me confused.