In my experience, the best way to manage this stuff is by using the finite state machine pattern. FIX order cycles, TCP connection states, IQFeed login sequences can all be coded as FSMs. That way, if anything unexpected happens, you'll know real quick if you've coded defensively. Also +1 to the...