On Feb 8, 2011, at 3:19 PM, James Bardin wrote: > On Tue, Feb 8, 2011 at 2:49 PM, Pieter Hintjens <[email protected]> wrote: >> Hi James, >> >> You would want to use XREQ and XREP sockets, probably, and manage >> timeouts using poll. There is a fairly detailed example of an RPC >> client and server in C, which can help give a design. >> >> https://github.com/zeromq/zfl/blob/master/src/zfl_rpc.c (client) >> https://github.com/zeromq/zfl/blob/master/src/zfl_rpcd.c (server) >> > > That would probably be the pinnacle of what I'm after, but it is > overkill for what I'm trying to solve right now.
Since the library does not support timeouts on REQ/REP sockets, then it isn't overkill. It's the only way available to solve your problem. > It would also take me > a while to go through the ZFL library to really comment on this (as > far as I see, there's no equivalent for the higher-language bindings). The python bindings should support zmq_poll(). As far as I know, those bindings support every facet of the 0mq library. Rebuilding the zfl functionality would probably be pretty easy in python. I've seen past discussions about integrating 0mq sockets with twisted, so it may already be done for you. > May a simpler question to get me going; > Is there a fast way to detect a server that's not available? With a > socket, I would get a "connection refused", and move on from there. > With zmq, it lets me send(), and then hangs on recv(). I could poll > the zmq socket with a timeout, but it seems an unavailable server > should be able to fail fast. No matter how you look at it, at some point you will have to poll on the socket and implement your own timeout. The library does not have this built in yet. In the case you mention above, zmq_connect() is an asynchronous operation. Unless it returns a non-0 value (which means it failed immediately), it will retry the connect in the background. Are you checking the return code from your calls to zmq_connect()? I think you are confused about the fundamentals of 0mq. It's unfortunate that they are called "sockets" because people new to the library always try to use them *exactly* the same as they would a posix socket. 0mq sockets have different semantics and require a different way of approaching and solving problems. cr _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
