Hello, so I'm working on another personal project and I want to write an improved sockets library for myself.
I currently have a basic Socket class written in a Socket.h and the implementation in Socket.cpp. It is contained within the namespace "Sockets". I'm going to write a derived TCPSocket class next inside of it's own files.
Sockets.h includes WinSock2.h. Is it common to place these types of header files in multiple files? TCPSocket uses functions, macros, etc from WinSock2.h as well.
Should TCPSocket.h just include Socket.h since Socket.h already has WinSock.h included? This has really stumped me and any design decision help would be much appreciated.
Try to avoid including winsock2.h in any header files at all and include it only in the cpp files.
It's bad practice to inject huge header trees into a project when it can be avoided (fairly easy for a socket class). It increases compilation times and in the case of the Windows headers, they add a whole bunch of nasty defines..
Personally, I wouldn't use a library that injects the Windows headers into my units (partly because it would break some of my projects due to said defines), if that counts for anything.