inetic / asio-utp Goto Github PK
View Code? Open in Web Editor NEWBoost.Asio wrapper over uTorrent's uTP library
License: Boost Software License 1.0
Boost.Asio wrapper over uTorrent's uTP library
License: Boost Software License 1.0
To make it more easily swappable with asio::ip::tcp::socket
https://www.boost.org/doc/libs/1_69_0/doc/html/boost_asio/reference/AcceptableProtocol.html
This code is incorrect:
boost::asio::async_completion<CompletionToken, write_signature> c(token);
do_write(std::move(c.completion_handler));
The problem is that do_write
receives the handler as a std::function
, which type-erases the handler. Later on, you call boost::asio::post
with this object. Since the function object is typed-erased, it loses the associated allocator and more importantly the associated executor. The consequence is that when a user writes:
auto const bytes_transferred =
utp_sock.async_write_some(
buffers,
boost::asio::bind_executor(strand_, my_handler));
The wrapper returned by bind_executor
loses its type information when it is stored in a function object. Then later on when you call post
, it doesn't go through the strand.
This is going to sound painful, but if you want your library to work nicely with Networking TS / Asio (and I think you have really nice library here, so you should want this) then you are going to have to do the following:
std::function
(and never use it again)These tutorials should help:
https://www.boost.org/doc/libs/1_69_0/libs/beast/doc/html/beast/using_io/writing_composed_operations.html
https://www.boost.org/doc/libs/1_69_0/libs/beast/doc/html/beast/using_io/example_detect_ssl.html
You might also consider studying the implementation of asio and beast. I can help with that by offering pointers and answering questions.
Continuing @vinniefalco's comment from issue #2:
Globals like this are a problem:
asio-utp/src/context.cppLine 41 in 994f50f
static std::map<endpoint_type, shared_ptr> loops;
Globals associated with anio_context
need to be installed usingasio::use_service
https://www.boost.org/doc/libs/1_69_0/doc/html/boost_asio/reference/use_service/overload1.htmlYour
context
is essentially a service, it just needs to be installed correctly.
As suggested on reddit
I'd like to know if Beast's HTTP stream algorithms work with asio-utp:
https://github.com/boostorg/beast/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.