Cross-platform simple TCP / IP API?

I am making a simple cross-platform chat program. I am using wXWidgets for a graphical interface that works well, but I need a way to create a socket and create a client server setup. Is there an API that, for example, uses WinSock for Windows, and a native Linux socket and osx?

I am not looking for enhancement as a solution, because I will make it open, and not everyone feels like installing a library with more than 70 MB.

thanks

+6
c ++
source share
5 answers
+5
source share

Winsock is fully compatible with the POSIX socket APIs, and most of the standard features are available in both. Headers are called differently, but a simple #ifdef can solve the following:

 #ifdef _WIN32 #include <winsock2.h> #else #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> // other headers you may use #endif 
+5
source share

wxWidgets has TCP client / server classes: see here

+1
source share

What about Apache runtime? Listed below are socket descriptions:

http://apr.apache.org/docs/apr/trunk/group_apr_network__io.html

0
source share

I answer this seven-year question in the hope that it will help someone someday (:

I was not able to find a cross-platform, lightweight API in sockets. (There are poco, boost asio and others out there, but they are large, comprehensive, and complex libraries)

So, I made a simple (and not complete) shell for POSIX and Winsock sockets here: https://github.com/soroush/libcpnet

0
source share

All Articles