Suppose you are writing an application that must implement the HTTP protocol. Protocols are quite complex and can allow several commands depending on what stage of the transaction they are.
As an example, consider SMTP. The SMTP server should give an error if the command "data" is sent before receiving "rcpt" and "mail".
My question is: what is the best way to handle such protocols in code? Are there any design patterns associated with this?
Edit: This question relates to protocol implementation theory. I know that using a library is the best approach in practice.
source
share