What is the difference between epoll and boost::asio::io_context?

Hwan E

I know that epoll and io_context work asynchronously. So, can you tell me what is the difference between the two?

Are you using epoll inside asio::io_context?

Asteroids With Wings

POSIX gives us a suite of utilities useful for dispatching on events and watching for activity on file descriptors. One of those utilities is epoll().

Boost ASIO also gives us a suite of utilities useful for dispatching on events and watching for activity on file descriptors. io_context is what it sounds like: a "handle" of sorts to a context for some I/O operations. Through an io_context you can poll() for activity (among other things).

They are two different interfaces for (in this comparison) a largely similar task. Boost ASIO, however, is an abstraction. Whether it uses epoll() under the bonnet to implement its magic is not really something we need to or should concern ourselves with, but it's certainly possible that it does so on POSIX systems. On Windows systems it would likely delegate to something else that the OS provides.

One school of thought is that cross-platform abstractions are always helpful, so the Boost ASIO technologies are a good choice for networking. On the other hand, some people find the old POSIX utilities to be simpler and more familiar to other programmers reading their code (as long as their target platforms support them); they also do not require you to ship a dependency. As with anything, it is up to you to decide which is the most appropriate for your use case and audience.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What's the difference between asio::io_context and asio::thread_pool?

What is the difference between Qt event handler and boost ASIO's io_service?

Confused on boost::asio::io_context::run() and boost::thread::join()

Boost asio io_service vs io_context

c++ error: use of deleted function boost::asio::io_context::io_context

Prevent boost::asio::io_context stopping on empty poll call

Confusion about boost::asio::io_context::run

Beginning on boost::asio : Having problems using io_context

What is the difference between post and dispatch from boost::asio when overloads with executor parameter are used?

Error E013 namespace "boost::asio" has no member "io_context"

Prevent boost::asio::io_context from returning when there is no more work to do

Get io_context reference from a socket in Boost 1.73+ Asio

Exceptions disappear due to boost::asio::co_spawn how to propagate via io_context::run

Which io_context does std::boost::asio::post / dispatch use?

boost::asio::io_context::run_one_for() fails to send large buffer

Boost::Asio io_context::run Unknown Visual C++ Runtime Error : Debug Error

Is there a way to explicitly destroy all handlers pending on a given boost::asio::io_context?

bad_weak_ptr while using class inheriting from boost::asio::io_context::service

Boost ASIO: Handling synchronous and asynchronous operations in the same class using the same io_context

Difference in boost::asio::io_service behaviour between GCC and MSVC: cannot cancel posted jobs

Difference between inotify and epoll

Difference between `deadline_timer`and `waitable_timer` in `boost asio`

boost::asio no handler called when using post(), works when function called directly (io_context has work)

What are the biggest differences between boost.asio and the current networking TS?

What is the difference between std::deque and boost::deque?

Can boost::asio::ssl::context be shared between multiple SSL streams?

In the context of boost::asio, what is the metaphor behind the term "strand"?

According to the doc of boost 1.68, old io_context::post is deprecated. boost::asio::post() is recomanded. Can anyone give me an example?

What does boost::asio::io_service::run() actually do?