A client of mine wants me to make a high performance, reliable server which receives datastreams via sockets. He expects it to be in c++
It's been a while that i was doing c++ fulltime so I've been reading up a bit. Asio seems to be a good bet for networking in c++, and c++11 seems like a great new version of c++ with a lot of new features.
My question: is it possible to use both reliably? Does it make sense? Should I avoid certain c++11 features like lambdas?
You can use the two of them together with no issues. For things implemented in both Boost and the C++11 STL, it's your choice which to use. In most cases, it makes very little difference. If you use Boost, you'll be portable to C++03 platforms as well (at least, that part of your code will be if it doesn't use C++11 features directly).
Boost was carefully designed to be able to take advantage of C++11 features where they are available without having to provide a "dumbed down" interface or poor performance to support where they're not.
And if you need good asynchronous I/O, you need some library to provide it. Boost is pretty hard to beat, whether you're using C++11 or not.
If your question is "Is there some specific reason I wouldn't want to use Boost with C++11 or C++11 with Boost", the answer is no. If you need some feature Boost provides, like asio, and only need to support C++11 platforms, then they're a perfect match for your application.
I'd base "C++11 features to avoid" primarily on your planned target compiler(s). I don't see any reason to avoid lambdas -- all the major compilers already support them, and the they provide a substantial improvement in readability.
On the other hand, depending on the compiler(s) you care about, you might want/need to avoid things like variadic templates and/or braced initializer lists.
See, boost.asio is network library for event driven programming - lots of callbacks, C++11 lambda makes writing callbacks very easy.
Basically combination of C++11 and Asio makes it much easier to develop and would make your code much more clean and readable
asio 文档特别提到了c ++ 11支持
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.