views:

11724

answers:

21

I haven't done work in C/C++ for a little bit and was just wondering what people's favorite cross platform libraries are to use.

I'm looking for something that is a good quick and dirty library as well as a library that is a little more robust. Often those are two different libraries and that's okay.

A: 

Boost

Joe Skora
kinda unhelpful, especially if questioner is unfamiliar w/Boost. Suggestion: add a link to Boost.asio
jwfearn
A: 

I guess it would depend on what platform you are on... WinSock2 is by default the most widely used on Windows.

Maverique
+5  A: 

Boost.Asio.

Chris Jester-Young
+25  A: 

Boost.Asio is really good, though the documentation is scarce.

ACE is also good, a bit more mature and has a couple of books to support it.

C++ Network Library looks promising.

Ferruccio
Boost.Asio is like bear bones Objects on wire. Ace is a higher level of abstraction and includes a <b>lot</b> of other stuff (its also a bit dated if you look at the source).
Martin York
Boost is very good and it has the advantage that the new standard library for C++0x will be based on it to a large extent. I've used ACE extensively and I dislike it: it imposes too much of its own architecture, it doesn't mesh with STL, the code is not readable, and the documentation is not good.
Cayle Spandon
I'd rather program directly with BSD sockets than use ACE's networking stuff for another project. It is pretty hard to understand and use unless you have an ACE book right there. It also is less "C++-ish" and more overzealous object oriented (you may like that though).
Greg Rogers
+1  A: 

Just to clear up any confusion, is the answer to the best C++ library for anything always BOOST?

Martin Beckett
If it's on something that Boost has a library for, probably.
KTC
Ask for a GUI library, and it won't be Boost :)
Nemanja Trifunovic
Not always "best", but usually pretty darn good. For a lot of C++ problems where you need/want a library of solutions, Boost is probably your best starting point. There are some exceptions of course--some of the Boost libraries are eclectic--but the overall quality of Boost is quite high.
sstock
+3  A: 

For robust, mature, and full-featured, it's hard to beat ACE. It has respect and acceptance in the aerospace industry, which is where I came into contact with it. A lot of the literature in modern distributed systems design, such as the Reactor and Proactor patterns, came out of Professor Schmidt's work in ACE.

Avdi
+1  A: 

Since Boost was already mentioned, I've got 2 more:

ACE: http://www.cs.wustl.edu/~schmidt/ACE.html

The ADAPTIVE Communication Environment (ACE(TM)), An OO Network Programming Toolkit in C++.

APR: http://apr.apache.org/

"The mission of the Apache Portable Runtime (APR) project is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementations. The primary goal is to provide an API to which software developers may code and be assured of predictable if not identical behaviour regardless of the platform on which their software is built, relieving them of the need to code special-case conditions to work around or take advantage of platform-specific deficiencies or features."

One of APR's goals is portability.

Kyle Burton
Make these separate answers so people can vote on them individually.
Adam Mitz
Read the subversion postmortem. They used APR. They said if they had to do it again they wouldn't use apr.
caspin
where's the subversion postmortem. I'm quite suprised to read that the wouldn't use libapr again. I have used it and was quite fond of it an it "simply works"
Friedrich
+2  A: 

It depends on how near the "implementation" you like to get. One can say (more or less) that nearly all TCP/IP stuff is based on the Berkeleys implementation, be it some windows or some unix it "nearly does not matter". There exist a few higher level libraries based on it, e.g the above mentione apr library is a good example. There are also extra implementation is the glib http://library.gnome.org/devel/glib/stable/glib-IO-Channels.html and surely other libraries like nspr and how they are all named. One of my "favourites" still wasn't mentioned. It's libcurl: http://curl.haxx.se/libcurl/

Regards Friedrich

Friedrich
libcurl is great but I believe it only does HTTP, no? The OP provided very little details and did not indicate the protocol he wanted to use.
bortzmeyer
No it does not do only HTTP it does HTTPS, FTP and much morehttp://curl.haxx.se/ Regards Friedrich
Friedrich
+5  A: 

Just to clear up any confusion, is the answer to the best C++ library for anything always BOOST?

Usually. And if Boost doesn't have it, the answer is inevitably 'Write one for Boost'. In general, boost can be considered to be the nonstandard standard library, and if you code C++ without Boost, you are probably wasting time.

coppro
You sound a little crazy, fanboy-ish. You are however correct.
caspin
+2  A: 

Berkeley Sockets is reasonably cross platform. What are you looking for beyond the basics provided there?

Adam Davis
In particular, Windows' tiny incompatibilities make this more annoying that you'd think. That's what is meant by cross platform: the ability to do without the pain of dealing with each individual platform's idiosyncrasies.
Yang
+5  A: 

If you want a fast library, try Raknet.

Raknet is built for game development, but because of this, it has high performance and reliability. You can watch a video of their features here

MrValdez
The link you provided is broken. [This](http://www.jenkinssoftware.com/raknet/manual/RakNetMajorFeatures.html) one works though.
GenTiradentes
Thanks for the heads up. Updated.
MrValdez
+1  A: 

If you are looking for a high performance network framework, you should take a look at a project coming out of Cambridge, UK called yield.

http://code.google.com/p/yield/

I would not describe it is a "quick and dirty" library, as there is a significant learning curve involved, mostly due to the fundamental difference from "normal" networking approaches; yield is a Staged Event Driven Architecture and is inherently asynchronous...

ceretullis
A: 

I'm with Adam - Berkeley socket code is portable and lot easier to figure out that Boost asio IMHO. I wrote a cross-platform socket class using Berkeley socket code easily enough, without any platform specifics IIRC.

However, asio is a very powerful library and can take advantage of platform-specifics which may be crucial if you are writing a heavy-duty network application, but in practice in can be quite difficult to implement.

Rob
A: 
Dan
A: 

WvStreams is an excellent C++ networking library that I find makes easy things easy and hard things possible.

apenwarr
+3  A: 

I'll second or third or whatever BoosT.ASIO just to add that while the documentation is fairly sparse, the tutorials and examples are quite good and should be enough to get you started. I've found it to be fairly well performing, as well.

Dave Tarkowski
+1  A: 

I wrote my own cross-platform library, as I wanted as light as possible, often used in Games, but working both for Unix and Windows. I prefer nonblocking style code, without using threads.

LION

LION Documentation

Took a little while to implement things like fork() for system()/popen() calls, but I'm pleased with the result.

+8  A: 

Not that I would prefer this to BOOST:ASIO, but In order to inform you:

POCO:

The POCO C++ Libraries aim to be for network-centric, cross-platform C++ software development what Apple's Cocoa is for Mac development, or Ruby on Rails is for Web development — a powerful, yet easy to use platform to build your applications upon.

The POCO C++ Libraries are built strictly on standard ANSI/ISO C++, including the standard library. The developers of the POCO C++ Libraries attempt to find a good balance between using advanced C++ features and keeping the classes comprehensible and the code clean, consistent and easy to maintain.

Comptrol
IMO Poco is an excellent choice. It is written in modern yet readable C++ style and the header files are very well documented.
StackedCrooked
Yet the networking library enforces a single thread per connection model on you.
Hassan Syed
A: 

I really like libevent. It is very scalable and gives you timers and HTTP support right out of the box. It has an active community and fairly good docs.

twk
+1  A: 

Zeroc

Ice for C++ supplies the raw power required by performance-hungry distributed systems, without forcing users to struggle with an arcane middleware API. The Ice language mapping for C++ enables programmers to be immediately productive and reduces development and maintenance costs by eliminating the need for explicit memory management. Productivity is further enhanced by using the Standard Template Library for data types, eliminating memory leaks with automatic garbage collection, and the availability of a wide variety of useful tools and services including documentation, security, deployment, and database integration. All Ice language mappings are fully interoperable.

Comptrol
A: 

Sorry to reopen the thread.

Whats wrong with BSD sockets, yes that is a honest question.

Ive been writing a large multi node networking system and iv'e only ever even thought of using raw sockets. Ive known there were other options but the cost factor in figuring everything out and having to make my program work according to their library always seemed worse.

So fist question: What are the major benefits of using a library like boost:asio or ace.

Second: What are the portability of Boost:asio to embedded devices (could be arm or xscale or other).

I'm not looking for an in depth answer to either question that seems suitable for another forum or thread. I just want a quickie :)

Dave Mathis
Window's WinSock is close to BSD sockets, but what differences exist (sockets are a different type, `send`/`recv` have different function declarations, things like `getsockname` and `getpeername` work differently, WSA*, `closesocket`... the list goes on.) are enough to make one want a wrapper library.
Thanatos
Also, ASIO does other things, like an event loop - it wraps around all the different methods of doing high performance `select` such as `epoll`, `kqueue`, whatever method Windows uses these days, etc. (but they're all completely unportable by themselves.)
Thanatos