I am programming a Client/Server application for my project in C++. The whole application protocol was given or discussed by the working group. The main idea is that we have 3 protocols.
- Text-protocol: send and receive some information in string format between client and server.
- Binary-protocol: client sends continiously some status data to server.
- Binary-protocol: client sends continiously some data like sound/video/images/text
All Protocols should run on different ports. I implemented a Socket-Class, which is responsible to create and listen socket, accept the connection from the client. Also there is a function to receive/send string-based data and receive/send binary-based data.
In the next step I wanted to define 3 Classes. Each of them should be responsible for creating one socket in new Thread and responsible for the protocol, which was defined for that port (s. 1-3). So at the end I will get 3 Sockets (1 Socket for one Port).
My question is, if I think in right direction? Maybe you can recommend my some design patterns for using different application protocols. It would be great if you can recommend me some projects or code, which can be similar with my project.
Thank you.
boostlibrary?boostfor generic sockets, it will make things easier for you and let you concentrate on the project-specific functionality, but its up to you. I do agree with the responder below though that a generic socket implementation should be common to all the protocols and separate of them.