Hello,

I don't know if it's the right place to ask but I didn't find any information on zmq side. I found a strange behaviour using zmq rust binding. I start a task that loop and after I start another task that bind a port and way to receive a message. The zmq recv call block the first task that run only when the second task is receiving a message.

The only way I found is to use the ZMQ_NOBLOCK (1) flag but I found strange that a blocked task can block all other task.

I test on linux (Ubuntu 1204) with the master trunk of Rust (cloned on 10/20/13) and the trunk of rust-zmq. My version of zmq is 3.2.4.

Any idea?

The code :

extern mod extra;
extern mod zmq;

use std::rt::io::timer;

#[main]
fn main() {
    println("hello?");

    do spawn ||    {
        loop {
             timer::sleep(500);
            println("coucou");
        }
    }

    do spawn || {
       let context = zmq::Context::new();
        let responder = context.socket(zmq::REP).unwrap();

        assert!(responder.bind("tcp://*:5555").is_ok());

        let mut msg = zmq::Message::new();
        loop {
            responder.recv(&mut msg, 0);
            do msg.with_str |s| {
                println!("Received {}", s);
            }
            responder.send_str("World", 0);
               timer::sleep(100);
        }
    }

    timer::sleep(10000);

}

Philippe Delrieu

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to