开发者

Cross platform Networking API [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

Improve this question

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.


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.


most of the berkeley sockets api works everywhere.


You can use ACE or Boost.Asio:

About ACE:

Increased portability -- ACE components make it easy to write concurrent networked applications on one OS platform and quickly port them to many other OS platforms. Moreover, because ACE is open source, free software, you never have to worry about getting locked into a particular operating system platform or compiler configuration.

About boost:

Boost.Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.


The NRL has a really great library of networking methods that supports a large variety of platforms. They have excellent support from the actual developers on their mailing lists as well.

Protolib


For this simple application you can use the standard "Berkeley socket" functions that are mostly portable. You can also use Boost's abstractions.

If you needed security functions like SSL/TLS (which you don't need for a simple game I guess), there are open source libraries like OpenSSL, GNU TLS, Mozilla NSS.


I've got a feeling the Apache Portable Runtime might help with what you're looking for. Apache HTTPD used this library internally to abstract its platform-specific code so that the server code focuses on the logic and calls the methods in the APR and these translate to underlying operating system functions.

Of course, it might have more tools in it than you strictly need...


Synapse is good multiplatform network library. Open source and very easy to use.

http://www.ararat.cz/synapse/doku.php/download


SDL Net is a very simple abstraction layer on top of sockets, that's very easy to use. See http://www.libsdl.org/projects/SDL_net.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜