well the docs on boost's thread lib isn't as good as the asio lib...
And after reading this: http://www.boost.org/doc/libs/1_44_0/doc/html/thread/synchronization.html I got the main idea but there is no codes and examples, that I could find, using that.
I would be happy for a link or explanations on how using that..
These two tutorials might help as they have code examples.
this has a section on multithreading which gives an intro to synchronization objects
Another one from Dr. Dobb's has an intro.
Related
Which book is worth buying, for your opinion? I'm generally familiar with multithreading concepts, OpenMP, basic WinAPI threading. I want now to learn to use new std::thread or boost.thread effectively - I'm unfamiliar with things like atomics, conditional variables, etc.
I don't know this book but the title got my attention: C++ Concurrency in Action. Perhaps it contains what you need, just take a look at the preview. It has some information about C++11
Can anyone find an example of a simple server/client thing? I'm willing to use any C++ library or even Winsocks it self. I've Googled around but want some opinion on a good article for beginners/sites.
If you're willing to use a C++ library, I heartily recommend Qt. It gives you an easy way to communicate with sockets, and much more. In particular see the QtNetwork module - a few of its relevant classes for your cause: QTcpSocket, QTcpServer, QUdpSocket.
see
http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html
If you are looking for a C++ networking library, I suggest Asio, which is now part of Boost. Start with the Tutorial. Also have a look at the examples.
JFGI
http://www.adp-gmbh.ch/win/misc/sockets.html
http://tldp.org/LDP/LG/issue74/tougher.html
I like ACE. It is a pretty large library but there are some core classes that are really easy to use for beginning network programming.
Here's a really good book for ACE too.
Ace Programming Guide
I've used Boost graph library a fair amount but not much of the rest of it. I frequently see recommendations here to use parts of Boost (say, Boost's various smart pointers). Obviously Boost is good and good to use. It is also large or diverse. Does anyone know of a FAQ or decent best practices doc to help a knowledgeable C++ programmer make better use of Boost?
You might find https://stackoverflow.com/questions/379290/how-to-learn-boost useful.
But in general, keep in mind that Boost is not a library, but a collection of libraries. Which means that you can and should use parts of it, but probably not all of it.
Just read over the list of libraries within Boost, and check the documentation for the specific libraries that sound useful. The Boost website is really the authoritative source, both on what Boost has to offer, and on how it should be used.
Pick out individual libraries that seem useful, and see what the Boost website has to say about them.
I learned the libraries I use by other developers suggesting certain libraries and me reading all the documentation I could find/needed to use the library.
However recently I bought this book, Beyond the C++ Standard, that introduces the most common parts of Boost. Even with reasonable boost experience I found this book really useful. It explains what the the libraries do, why they do it, how to use it and some of the techniques they use to implement it.
When some problem looks like a wheel which was invented already, firstly I look at boost's list of libraries and I trying to use that which will be appropriate for certain task. That's is my way to learn boost.
I'd like to do some network socket programming in C++ and have found the C++ Sockets library.
First, is this a good way to go in C++? Normally in C, I'd use some of the stuff beej describes in his tutorial.
Second, how do I compile the examples given on the site? I can't figure it out from their installation/configuration guide. So I download the tar.gz to my Linux box, then what?
To have a specific example, how do I compile and run the DisplaySocket example?
Thanks.
EDIT: Thank you for the quick answers. A comment though. I'm not really looking into "understanding" network programming as I think I do that well enough already. I want to know if there's anything in particular to take advantage of in C++, and - if "the C++ Sockets Library" is a good choice - how to use it.
That's not "the" C++ sockets library, it's "a" C++ sockets library. Boost.asio has another (http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio.html).
(Community Wiki since I can't actually help you with your question - I've never compiled the code you ask about, so I don't know at what point you might have tripped over a problem).
Network programming would be better understood by using basic socket api (BSD or WinSock) rather than a socket library which hides most of the intricacies about sockets and their behaviour.
I would second the vote for boost::asio since it encapsulates the inversion of control model that is the current, preferred model, and appears to be standard-bound. To learn what the documentation doesn't tell you, google Douglas Schmidt and his books.
I like to use the ACE networking library when I write networking code in C++. I think it does a nice job abstracting some of the intricate details away that make network coding painful but doesn't do it to the point where it hides what is going on under the hood. It also has facilities for threading and messaging which usually are needed for any project.
The documentation available on the boost website is... limited.
From what I've been able to read, the general consensus is that it is simply difficult to find good documentation on the boost::asio library.
Is this really the case? If so, why?
Notes:
I have already found the (non-boost) Asio website - and the documentation looks to be identical to that on the boost website.
I know that Boost::asio is new! I'm looking for solutions not excuses.
Edit:
There is a proposal to add a networking library to standard library for TR2 written by the author of Boost:asio (Christopher Kohlhoff). While it isn't documentation for boost:asio, it does use it as a base for the TR2 proposal. Since the author put more effort into this document, I have found it to be somewhat helpful, if not as a reference, then at least as an overview.
Some nice documentation on boost including a chapter on asio can be found in a (free) boost book at http://en.highscore.de/cpp/boost/index.html. The chapter on asio provides a general overview and then goes as far as how to develop your own custom asio extensions. Really fantastic effort by Boris Schäling!
First, I've been using Boost.Asio for quite a while already -- and I share your concern. To address your question:
There really is very scarce documentation about Boost.Asio aside from the introduction and tutorial. I am not the author, but this is mostly because there are just too many things to document for something as low-level as an Asynchronous IO Library.
The examples give more away than the tutorials do. If you don't mind spending a little time looking at the different examples, I would think they should suffice to get you started. If you want to run away with it, then the reference documentation should help you a lot.
Ask around in the Boost Users and Boost Developers mailing list if you're really stuck or looking for specific guidance. I'm pretty sure a lot of people will be willing to address your concerns on the mailing lists.
There are efforts (not part of Boost.Asio) to expose a lot of the functionality and possible alternative use cases. This at best is scattered around the web in blogs and other forms of non-packaged documentation.
One thing that is unclear and which will really need close coordination with the author and developers of the Boost.Asio library would be as far as extending and customizing it for a specific platform or adding specific new functionality. This should be improved though but the good thing is it's looking like Asio will be a reference implementation for a standard library technical report (for an asynchronous IO library in the STL) in the future.
I wrote two small articles that could be used as introductions to boost.asio. They are available from my site
NOTE: I have contacted gamedev.net to let them know about the formatting issues. Unfortunately at the time of writing this comment, this resource is more difficult to recommend because of some changes with their website which hide/delete the #include statements + a missing .zip file resource.
A relatively new and very good beginner tutorial for Boost.Asio (which also introduces how to use it effectively with bind, shared_ptr, and threads) can be found here:
http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting-started-with-boostasio?pg=1
Note: If you're using c++0x features many of the simple uses of bind for creating a functor can be replaced with lambdas, and shared_ptr/bind are also available in the latest version of visual studio (or gcc which also includes threads.)
When I was searching for documentation or a tutorial this question kept popping up at the top of search results, so it is important to keep it updated as new tutorials come around.
I came along to 3 videos that I've found helpful once you get past the official boost asio overview:
Thinking asynchronously - designing applications with asio
Are you ready for ipv6
Why c-0x is the awesomest language for network programming
And
Thinking asynchronously slides
Are you ready for ipv6 slides
Why c-0x is the awesomest language for network programming
slides
The asio documentation, the one available in boost, is minimalist but very precise, each word is significant. That said,I have learned asio (and continue to learn) mainly from SO.
In my opinion, the answer to 'Confused when boost::asio::io_service run method blocks/unblocks' is the very first step, read an read again until you really understand it, second answer is also helpful.
Then I have RSS subscribed to newest SO boost-asio tag question and to these two answerers:
Tanner Sansburry, the author of the answer above, his answers are always very precise, comprehensive, with references, even beautiful schemas. RSS feed
Sehe (sorry Sehe, only 2nd). RSS feed
With all that material, you will soon be an asio expert !
I was quite curious about that, too but this page gave me some head start. It's in French, but you could use google translate which is pretty readable (I had to follow down this path myself).
http://gwenael-dunand.developpez.com/tutoriels/cpp/boost/asio/
A little late to the party but there's a book out called "Boost Asio Network Programming" (Packt publishing).
I bought a copy of this, read it over the weekend and then wrote a full on server in C++ without much problem.
Disclaimer: I have nothing to do with the book
I stumbled on the following pdf:
http://boost.cowic.de/rc/pdf/asio_doc.pdf