Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross platform Networking API [closed]

I was wondering if there was an API to do networking that would work on Windows, Mac and Linux. I would like to make a card game that 2 people can play through a TCP connection.

like image 342
jmasterx Avatar asked Feb 06 '10 22:02

jmasterx


People also ask

How do cross platform libraries work?

Generally cross platform libraries are implemented in layers. There is the public interface, the common code, and a minimalized set of platform dependent code. The public interface usually uses #if defined(symbol) checks to determine which platform it is running on.

What is CPP Netlib?

cpp-netlib is a collection of network-related routines/implementations geared towards providing a robust cross-platform networking library.


2 Answers

There are a few options for this, some easier to use than others:

  • APR (Apache Portable Runtime) - Very popular. Quite easy to use. Includes lots of additional features handy for network programming (threads, mutexes, etc.)

  • ACE - Popular among the embedded space. Personally, I found it quite a complicated API, and not very straightforward to use.

  • Boost - If you have a decent level of sophistication with C++ (templates, metaprogramming, etc.), then Boost libraries are generally very good. I'm not sure how popular the Boost asynchronous networking libraries are in the real world.

  • QT - Popular as a UI toolkit, but has a great set of threading, event management, networking libraries. IMO, this is by far the easiest to use.

It's important to stay away from using the berkeley sockets library, as the implementations across operating systems vary wildly, and you'll lose a fair bit of time to tuning them as you port your software across OSs.

My personal preference: APR.

like image 119
0xfe Avatar answered Sep 30 '22 12:09

0xfe


most of the berkeley sockets api works everywhere.

like image 33
President James K. Polk Avatar answered Sep 30 '22 11:09

President James K. Polk