I believe a firm understanding of network programming is something every programmer should have in his armory. Although I know how to use the basics of socket programming to communicate between a client and a server I do not have experience of network programming "best practices".
To help me learn this I intend to write a client and server application like a messaing program, purely to help me learn how to use winsock correctly. The server will be ran on my PC and allow multiple buddies to connect to it and chat, share files, play games etc etc. To make it simple the multiple client buddies cant talk to each other but only to the single server buddy. The server buddy must be able to chat to multiple buddies at any time and show when each buddy is typing a message. It should also be able to read the status of buddies and acknowledge any changes to their screen name.
Now with my current winsock knowledge I can write the above program already but like most programming designs there is the right way to do it and there are many wrong ways to do it. It is the learning of the right way to do it that I plan to learn with this project.
So my question is to you is (without requring code examples just "best practices"):
How would you design such a system to make it stable, flexible and easily maintainable? Should the socket be wrapped in a RAII class and im assuming it should all be multithreaded for each buddy connection? If so how stable is winsock in a multithreaded environment?
Also how would you design the communication between the server and client so they communicate effectively in the face of errors, lost packets etc.
I know im asking quite a lot but I consider this knowledge to be invaluable.
Thanks for any help