title: Design patterns for network protocols?
body: <p>So I'm building a fairly simple file transfer server/client but having a hard time to figure out a good design for processing different commands and states within the protocol..</p>
  
  <p>Say that you have 3 different commands <code>upload</code>, <code>remove</code>, <code>download</code>, you could use 3 different if-statements and keep track of states with additional if-statements, but that wont scale and will be <em>impossible</em> to maintain..</p>
  
  <p>The Chain Of Responsibility design pattern could be used for sequential stuff such as encryption and compression, but it wont take care of the logic for commands.</p>
  
  <p>I know that this is a quite broad question, but does anyone have any suggestions?</p>