[zeromq-dev] description of REQ/REP state machine?

Michael Haberler mail17 at mah.priv.at
Tue Oct 2 17:33:53 CEST 2012


Am 02.10.2012 um 11:39 schrieb Pieter Hintjens:

> On Tue, Oct 2, 2012 at 11:33 AM, Michael Haberler <mail17 at mah.priv.at> wrote:
> 
>> I'd need a concise description of the REQ/REP state machine - which socket may send which message when, and the states a connection goes through
>> 
>> is there such a thing or is it reading zeromq/src/{req,rep}.cpp?
> 
> Calling it a "state machine" is a little tortuous. It's a single bit
> flag: on a REQ socket, ready to send to network, or waiting for
> response from network; on a REP socket, ready to receive from network,
> or waiting to reply to network.

reading the code and comparing it with a trace it strikes as a bit more complex than that - in rep.cpp it's two bits, makes four possible states, plus MORE bit interpretation, and a frame interpreted as identiy, which could be optional,expected or not allowed at all depending on socket type

I think such informal description is inadaequate for a independent protocol implementation, and I think I'm not alone with this view: http://lucumr.pocoo.org/2012/6/26/disconnects-are-good-for-you/

I'm happy to draw a message sequence diagram for inclusion in the manual once I get it, but I need some help on the exact flows and semantics first

---

it seems REQ sockets start out in 'network write' mode, REP sockets in 'network read'

it is unclear to me what constitutes the 'turnaround' event which makes the direction flip, and what constiutes the change of interpretation from path element to reply proper

is it correct to say REQ/REP sockets are strictly half-duplex? 

overlapping sends in both directions seem to cause a 'Operation cannot be accomplished in current state' error

- Michael


> 
> Which just prevents the caller sending twice, or receiving twice in a row.
> 
> -Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev




More information about the zeromq-dev mailing list