Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am building a tutoring application that multiple students can sign into the same session with a tutor.

My question is, for example, if I sent out a command to draw a line, do I need to wait to see that all connected students propagated the command. Now, it relies that requests will be processed in order.

But consider this. If I draw one point, drag and draw another point, it will draw a line. But if I don't wait to see if each step propagated to all students' screens successfully, a student might receive an instruction of drag, draw, draw.

However, waiting for each connected user's input seems to be a very slow approach. Is there any way I can solve this efficiently? Or is this a problem at all?

share|improve this question
    
Basically you're asking how to avoid race conditions in a networking system? –  Joe Z. Jan 5 '13 at 16:35
    
@JoeZeng, if the concept is named the same way for networks, then yes. –  jsn Jan 5 '13 at 16:39

1 Answer 1

up vote 2 down vote accepted

One way I could think of is to encode a unique numerical order for each draw instruction, so if they were sent out of order, the program picking it up would know that it was out of order and could correct the drawing accordingly.

I'm not sure this way is the best way, though, as it means that if the packets are wildly out of order, the drawing will fluctuate a lot.

share|improve this answer
    
It seems the ids for transactions should come from the server as well so there is a centralized order for commands/instructions. –  jsn Jan 5 '13 at 16:48
    
The numerical order would be generated by the server in the order that the draw commands are executed, and then sent out to the clients. You are correct. –  Joe Z. Jan 5 '13 at 16:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.