cpp_weekly
cpp_weekly copied to clipboard
We didn't get networking in C++20 (or C++23)! Now what?
cpprestsdk other networking libraries conan, vcpkg
I kinda hoped I would get networking in the STL since my web framework would totally benefit from it, but I did too think that asio was way too complicated and too different than the rest of the STL.
I think at this point someone needs to think about starting a new networking library from scratch with the mindset that it's going to be in the STL; not it :)
Anyone designing such thing must probably consider that someday other transport layer protocols like QUIC might find their way into STL as well.
And also I don't think anything higher than the transport layer of OSI should be considered (not that it's been ever haha) just yet.
POCO - https://github.com/pocoproject/poco
boost.asio here and I don't see that changing any time soon, even if networking TS was standardized as it did not provide all the features of ASIO such as serial port access, Unix sockets etc, only IP, which is woefully insufficient
I use asio, but I’d like something a bit simpler…
I have used Qt for TCP and HTTP(S), and I also have used a simple in-house cross-platform wrapper library for sockets, URL handling and HTTP (without SSL). IMO, any network support layer should be able to handle TCP, UDP, HTTPS with sufficient amount of customization for HTTP. For example, I have encountered a problem with SSL on some Windows machines that I couldn't get to the bottom of, but it could be a problem root CA / chain of trust. It was essential to be able to gracefully ignore SSL errors and establish a technically insecure connection over HTTPS. I also did some things for which access to and modification of HTTP headers was needed.
POCO - https://github.com/pocoproject/poco
That is very cool
I have used Qt for TCP and HTTP(S), and I also have used a simple in-house cross-platform wrapper library for sockets, URL handling and HTTP (without SSL).
Exactly the same here.
libtorrent
Uvw is great https://github.com/skypjack/uvw
Uvw is great https://github.com/skypjack/uvw
That's interesting! What makes it better than industry-standard libraries like POCO
or libcurl
? Or boost::asio
(I won't pretend I understand what asio
is for, but seems to have similarities with libuv
).
If I ever need to interface to a binary through the web, I usually just use a reverse proxy with nginx and listen locally in my application. Handles 99% of the annoyances that goes with having a server up and running... including the complexities of SSL.
Primary Note: We have package managers today! I evaluated Hunter, Conan and vcpkg for availability of each of these libraries.
From Twitter: https://twitter.com/lefticus/status/1564017510290075650
Defacto Standard:
- ASIO https://think-async.com/Asio/ - which is what the networking TS is based on. Can be used with or without boost conan, hunter, vcpkg
Larger utility libraries:
- Qt https://www.qt.io/ - has all the things. Just use it if you already use Qt vcpkg, conan
- wxWidgets - https://wxwidgets.org - Crossplatform GUI library with Networking vcpkg
- Poco - https://pocoproject.org/ more than just networking hunter, vcpkg, poco
More "low level" networking specific libraries:
- ACE - http://www.dre.vanderbilt.edu/~schmidt/ACE.html vcpkg (well respected, not on Github AFAICT)
- uvw - https://github.com/skypjack/uvw - wrapper around the popular libuv vcpkg conan (1.5k ⭐)
- Sockpp - https://github.com/fpagliughi/sockpp vcpkg (483 ⭐)
- Trantor - https://github.com/an-tao/trantor TCP specific vcpkg conan (239 ⭐)
libcurl wrappers
- cpr - https://github.com/libcpr/cpr hunter vcpkg conan (4.9k ⭐)
- curlpp - https://github.com/jpbarrette/curlpp vcpkg (1.3k ⭐)
- curlcpp - https://github.com/JosephP91/curlcpp (542 ⭐)
Message Passing Like Framework Things with Multi language Support
ZeroMQ
- https://zeromq.org/get-started/ (C++ and ASIO style bindings available) vcpkg conan
gRPC
- https://grpc.io/ hunter vcpkg conan (35.4k ⭐)
- https://github.com/Tradias/asio-grpc conan, vcpkg (142 ⭐)
Websocket/HTTP specific
- https://github.com/zaphoyd/websocketpp hunter vcpkg conan (5.8k ⭐)
- boost beast - https://www.boost.org/doc/libs/1_73_0/libs/beast/doc/html/beast/introduction.html hunter vcpkg conan
REST
- https://github.com/Microsoft/cpprestsdk (deprecated) vcpkg conan (7k ⭐)
- https://github.com/pistacheio/pistache vcpkg conan (2.7k ⭐)
- https://github.com/mrtazz/restclient-cpp vcpkg (1.4k ⭐)
- https://github.com/Stiffstream/restinio vcpkg conan (879 ⭐)
- https://github.com/jgaa/restc-cpp vcpkg (488 ⭐)
Thousands of us will keep on using MPI for another decade at least.
The networking TS was a huge disappointment for me and I hope C++ takes a very different strategy next time.
@jeffhammond: I think you completely missed the point, MPI is its own thing and is absolutely out of scope for this discussion of general-purpose networking. Of course people will keep using MPI.
https://github.com/5cript/roar My own :P for http(s) and websocket based on boost::beast and curl. Otherwise asio, beast, libcurl
@jeffhammond: I think you completely missed the point, MPI is its own thing and is absolutely out of scope for this discussion of general-purpose networking. Of course people will keep using MPI.
MPI is far more general - and sockets far less general - than you seem willing to admit. In any case, I don't want C++ to pull in MPI, just consider more than sockets.
Look at libfabric or UCX as examples of alternatives to sockets that are capable of expressing high performance networking patterns across a range of technology.
@jeffhammond: interesting pointers, thank you! I know MPI but never heard of these two libraries.
On generality: a Turing machine is much more general than an ARM or x86 CPU, or than the C++ abstract machine, but it doesn't mean we should all be programming for the Turing machine.
Coming in Episode 345
I'll plug mine. :-)
https://github.com/omnifarious/StrMod
It's kind of odd, it's kind of a co-routine thing without co-routines. The co-routine state is kept in StreamModule objects. It has ropes for managing the data coming in and going out. I wrote it a very long time ago, but I do keep it somewhat up-to-date. I've written a couple of commercial things with it.
I recently modified it to build as a CMake package. I don't know if that means it'll work with one of the C++ package managers or not. When module support is more baked, I'll probably make it use modules, though I don't make heavy use of templates and so that will probably not speed up compilation much.
Would it be worth mentioning something like epoll
here?
Would it be worth mentioning something like
epoll
here?
May as well post a link to it!
epoll is just one of the low level ways on linux to wait for IO events. https://man7.org/linux/man-pages/man7/epoll.7.html There is also the new io_uring, which is potentially better than epoll and can also be enabled as an implementation in boost asio using BOOST_ASIO_HAS_IO_URING
It is also worth pointing out that aedis(redis client), restinio, crowCpp are based on asio. For Qt restAPI there is also cutelyst.
I've done detailed presentations on POCO, restbed, pistache, Cap'nProto and ZeroMQ for Utah C++ Programmers on our Network Programming playlist.