What is a popular, multi-platform, free and open source socket library [closed]

0 votes
asked Oct 19, 2009 by ata

Is there any free open source library (in C/C++) for sockets that is widely used and supports wide range of operating systems (Windows, Unix/Linux, FreeBSD etc). Just like pthreads.

Otherwise the only solution left would be to write socket wrapper for each operating system. Or would writing a wrapper against winsock and GNU C sys/socket.h libraries would be enough?

Wouldn't it be possible that I implement it against the socket library provided with GNU C. GNU C is available for wide range of platforms and my code will work in all those platforms?

10 Answers

0 votes
answered Jan 19, 2009 by chris-becke

There is only one correct answer here. OpenSSL. Because once you have socket code, youre going to want to make SSL connections too. If you are already working in a particular cross platform framework, OpenSSL bindings might already be avaialable. I don't think theres much excuse now to not SSL/TLS enable your application from the get-go.

0 votes
answered Oct 19, 2009 by tobias-langner

QT if it isn't too big for you. Boost has some network code as well. wxWidgets has with wxNet a network library as well. Another lib is Clanlib. And of course SDL

0 votes
answered Oct 19, 2009 by carl

Consider looking at boost?

0 votes
answered Oct 19, 2009 by unwind

Yes, you will get very far with a wrapper around Winsock and standard Berkeley sockets. In fact, the differences are so small it's almost possible to do it with #ifdef directly in the code.

That is, if you're willing to work at the socket level. If you're after something more abstract, then of course wrapping it gives you a good opportunity to also hide the differences.

In particular, Winsock:

  • Requires you to "start it up" by calling WSAStartup() before any other socket function
  • Does not allow you to use plain old close() on a socket; you must use closesocket()
  • Requires that you use WSAGetLastError() to get the last error, not plain errno.

Those are the three major ones off the top of my head, there might be more.

0 votes
answered Oct 19, 2009 by satbir

ACE may Help you !

This tutorial provides an overview of the ACE OS adaptation layer and the design and use of its C++ Socket wrappers

Developing Efficient and Portable Communication Software with ACE and C++

0 votes
answered Oct 19, 2009 by chris-lutz

I believe both the Apache Portable Runtime and GTK+'s GLib libraries have socket APIs. Since your question is tagged c and c++ I suspect you really want C++-centric answers, but both of these are good as pure C libraries.

0 votes
answered Oct 19, 2009 by james-turner

If you want a very light, C++ only, iostreams-style wrapper around BSD sockets, you could consider skstream - it's simple and works well. Of course, the iostreams interface itself leaves much to be desired. skstream does wrap select and the very low-level socket handling up for you quite nicely, though.

0 votes
answered Oct 19, 2009 by davit-siradeghyan

Use boost::asio. Very good library. Follow this link http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio.html

0 votes
answered Oct 19, 2009 by lsalamon
0 votes
answered Oct 19, 2009 by blwy10

Another option you can try is Poco. Poco has a lot more than sockets as well, so if you need other stuff it can provide as well.

Comparing it to other toolkits:

  1. Qt has GUI and some very sophisticated features you won't find in Poco, but it's a lot bigger.
  2. Boost doesn't have as much as Poco in the way of actual functionality, but it has libraries like reference wrappers, MPL and preprocessor which cannot be found anywhere else.
  3. I don't remember ACE very well, but I remember it was very very big in terms of source code and components. ACE seems to be used for very high performance network applications, so it may be overkill. But then again, I'm not too sure.

Just my two cents

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