I'm making a simple cross platform chat program. I'm using wXWidgets for the GUI which works well, but I need a way to create a socket and to create a server client setup. Is there an API that for example underlying uses WinSock on Windows, and Linux's native socket and osx's?
I'm not looking for boost as a solution because I will be making it open sourced and not everyone feels like installing a 70+ MB library.
Winsock is quite compatible with the POSIX socket APIs, and most of the standard functions are available in both. The headers are named differently, but a simple #ifdef
can solve that:
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
// other headers you may use
#endif
The QtNetwork module
wxWidgets itself has TCP client/server classes: see here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With