Giter Club home page Giter Club logo

asio-utp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

equalitie

asio-utp's Issues

Does global `udp::socket` store need to be implemented as an Asio service

Continuing @vinniefalco's comment from issue #2:

Globals like this are a problem:
asio-utp/src/context.cpp

Line 41 in 994f50f

static std::map<endpoint_type, shared_ptr> loops;
Globals associated with an io_context need to be installed using asio::use_service
https://www.boost.org/doc/libs/1_69_0/doc/html/boost_asio/reference/use_service/overload1.html

Your context is essentially a service, it just needs to be installed correctly.

Don't type-erase the CompletionHandler

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:

  • Remove all use of std::function (and never use it again)
  • Move everything in the .cpp files into header files (this library must be header-only to work right)
  • Rewrite your asynchronous operations (connect, read some, write some) as composed operations

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.