Cross platform simple TCP/ IP API?

0 votes
asked Nov 21, 2010 by jmasterx

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.


5 Answers

0 votes
answered Nov 21, 2010 by hhafez

The QtNetwork module

0 votes
answered Nov 21, 2010 by casablanca

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>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
// other headers you may use
0 votes
answered Nov 14, 2011 by erik-olson

How about Apache Runtime? Here is the page detailing socket definitions:

0 votes
answered Nov 14, 2011 by highcommander4

wxWidgets itself has TCP client/server classes: see here

0 votes
answered Sep 15, 2017 by sorush-r

I'm answering this seven years old question in the hope that this helps someone, someday (:

I have failed to find a cross-platform, lightweight API on sockets. (There is poco, boost asio and others out there, but they are big, comprehensive and complex libraries)

So I made a simple (and not complete) wrapper on POSIX sockets and Winsock here:

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter