I am writing client / server app in C ++ and the simple protocol to send and receive data correctly Have to realize. I have a class of server protocol that can convert the message to my format and then convert it to this format again.
What the server-side protocol looks like:
class BaseProtocol {protected: int numberOfBytesInPackOfText; Std :: string serviceString; Public: BaseProtocol (Interea SizeOftextPak, Const four * Extra string): NumberOfBytesPackOftext (SizeOfTestPac), Servicing (Extra String) {} Virtual Study :: String & amp; Convert ToSystemMessage (const char * message) = 0; Virtual std :: String & amp; ConvertTalMessage (Const four * messages) = 0; Virtual ~ Base Protocol () {NumberOfBytesInPackOfText = 0; ServiceString = ""; }}; Class Simple Protocol: Public Base Protocol {Public: Simple Protocol (Integer SizeEftextPack, Const. Four * Service): BaseProtocol (SiegfixPak, Service) {} std :: string & amp; ConvertiTystemMouse (Cons Char * Netmate); Std :: string in & amp; ConvertTailmessage (Const four * system messages); };
Now I can not decide what would be a better decision for implementing that protocol on client applications. A Friend class for server protocol? Or maybe I need to remove the subclass from the server protocol, and then the client protocol will be derived from this class?
I will make a protocol class independent of both client and server. Instead of receiving each class from the classroom, they can call the functions of that class.
It follows the principle In addition, neither the client nor the server is the "one" protocol interpreter, but only requires the use of the protocol.
Comments
Post a Comment