[zeromq-dev] bind/connect assimetry

Ilja Golshtein ilejncs at narod.ru
Thu Jan 20 10:32:32 CET 2011


Hello,
dear list!

Is it expected send blocks against bound socket without counterpart
and does not against connected socket without counterpart?

==
dev:~/projects/zeromq-play >cat bind_send.cpp
#include <iostream>
#include <zmq.hpp>


int
main(int argc, char** argv)
{
  zmq::context_t ctx(1);
  zmq::socket_t s(ctx, ZMQ_PUSH);
  s.bind("tcp://*:23333"); // no pair
  zmq::message_t query(10);
  std::cout << "before send" << std::endl;
  int ret = s.send(query, ZMQ_NOBLOCK);
  if (!ret)
  {
    std::cout <<  "ret is " << ret << ": " <<
      zmq_strerror(zmq_errno()) << std::endl;
  }
  std::cout << "sent" << std::endl;
}

      
dev:~/projects/zeromq-play >./bind_send
before send
ret is 0: Resource temporarily unavailable
sent
==


If connect not bind
==
  s.connect("tcp://*:23333"); // no pair
==
everything goes smoothly and the result is just
==
before send
sent
==

Is it expected behavior? 
I wonder if one of 0mq goals is to isolate application programmers from right bind/connect order (leaving out of the scope inproc issue),
why bound and connected sockets are [sometimes] different?

Thanks.

-- 
Best regards,
Ilja Golshtein.

PS. 0mq version is 2.0.10, Linux kernel 2.6.18



More information about the zeromq-dev mailing list