From: snacktime Date: 2006-09-10T06:08:15+09:00 Subject: Re: state machine in ruby > > Chris, unless I'm missing something, this seems like a very simple protocol. > I'm sure you left out some stuff like the end-state signalling, the goodbye > kisses, etc. But there aren't very many state transitions here. At first > glance it looks like a nonpipelined request/response protocol like SMTP (but > far simpler than SMTP). The only confusing thing here is the 60-second > timeout. If the server doesn't respond to a request for 60 seconds, is the > client supposed to assume that the server will *never* send a response? Or > is there some correlation built into the requests and responses so the > client can later recognize a delayed or out-of-order response? > The difficult part is the error correction, at least for me not having worked with state machines that much. There are several points in the protocol where an error can occur, and you have to switch states, handle the error, and then possibly jump back to where you left off if the error is resolved. Some of the trees go 5-8 levels deep, and most of them have their own timers which can also decide which state you transition to next. For the timers, some of them you just disconnect after a certain time, and some of them are the time to wait before changing state. For instance if you get an ACK within 3 seconds go to state A, otherwise state B.