Giter Club home page Giter Club logo

asio2's People

Contributors

astr0mfly avatar heheda123123 avatar zhllxt avatar

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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asio2's Issues

rpc问题

在绑定的函数里面调用async_call会异常,会导致OnRegister函数调用两次,SetSessionID返回失败
image
image

使用例程中的http服务,建立websocket连接时发生Assertion failed

将asio2\example\http\server中的http服务例程编译,当采用debug启动时,在建立websocket连接时将会发生Assertion failed,而采用release时便可以正常运行

Assertion failed: derive.sessions().io().strand().running_in_this_thread(), file D:\Develop\Lib\asio2\asio2\http\component\ws_stream_cp.hpp, line 83

是否可以支持异步发送?

看代码tcp都是同步发送的,是否可添加异步发送?另外tcp接收到消息的时候,如果不是整个消息包,应用程序还需要自己保存接收的数据,是否可以添加操作告诉回调函数处理了多少字节,还有多少字节没处理,让调用回调的函数自己处理没有使用的数据.

3rd目录建议手动git引入

3rd这个目录能弄成手动git引入不,这样我们工程自动clone以后就不会下载那么多用不到的东西了

g++ v7.3.8编译报错

image

template
inline void _handle_accept(const error_code & ec, std::shared_ptr<session_t> session_ptr,
condition_wrap condition)
{
set_last_error(ec);

		// if the acceptor status is closed,don't call _post_accept again.
		if (ec == asio::error::operation_aborted)
		{
			this->derived()._do_stop(ec);
			return;
		}

		if (!ec)
		{
			if (this->is_started())
			{
				session_ptr->counter_ptr_ = this->counter_ptr_;
				session_ptr->start(condition);
			}
		}

		this->derived()._post_accept(std::move(condition));
	}

这里明显counter_ptr_和start 是session_ptr的protected不能调用吧

关于异步操作使用strand的疑问

最近在拜读源码,对于每个tcp连接绑定一个io对象,一个io对象会同时创建一个strand并且只运行于一个线程中,所有tcp异步操作都会在绑定的ioc线程中执行并且使用strand,如果ioc只运行于单线程的情况下应该不存在线程竞争,那为何要使用strand?这里想不明白

qt 和vs2017下编译异常

qt5.9.8下提示需要c++17,在pro文件中配置了config+=c++17也没有用。在vs2017下可以编译,但智能提示用不了,凡是引用了asio2的都用不了智能提示,编译也有智能提示方面的错误;代码编辑界面上很多函数和变量都飘红。

是否支持https?

我需要一个接口,接口的功能是收到服务端带着证书的response后,客户端可以忽略掉证书,所以前提肯定需要支持https。
所以这个库支持https吗?以及有没有相关功能的接口?
感谢回复

http client使用ip请求报错

使用Http client请求内网接口,报错400 :

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

我的使用方式:
std::string url = "https://192.168.2.3/aaaaaa";
http::web_request req2 = http::make_request(url);
req2.method(http::verb::get);
auto rep2 = asio2::http_client::execute(req2);

以上请求,使用curl或者postman是可以请求到内容的。

TCP测试数据传输问题

在进行TCP数据传输的时候,如果一个client同时向server发数据,server接收的数据就会合并在一起。应该原因就是采用的异步接收方式导致的,那么对于这种情况的话,是采用同步方式来改程序好还是在现有代码下有解决方案?
代码里采用的都是async_read,这里能否改成同步的read呢,我自己试了下不行。

http服务手动应答的问题

示例代码,创建http服务,相同client(tcp)链路多次请求,第二次服务就收到数据了。使用的异步http服务。

可靠UDP模式使用问题

你好:
我在使用可靠UDP的时候,发现一个这样的问题:启动了client和server,然后我直接关闭了client或server,在重新启动一个对应的client或server,发现不会重新连接,而且等待的时间特别长。也就是说当一个client或者server异常崩溃后,收不到对应的断开信号,我试了一下tcp的那个,tcp那个就可以,断开后,直接在启动,会自动连接上。
想问一下udp的可靠传输下,这个问题怎么解决?

关于 rpc异步调用的接收顺序问题

rpc client/server 连接建立后
在client端用async_call 调用同一个方法,在server端的接收顺序是随机的还是按client端的调用顺序到达的?

如果client端在同一个线程用async_call 连续多次调用同一个方法,在server端的接收顺序是否按调用顺序到达?

关于同步调用的线程问题

rpc server/client 的同步调用call 是不是只能在创建对象的线程调用 ,或者说是不是不能在任意的线程中调用 ?
因为_do_call 里面有个断言
// Unable to invoke synchronization rpc call function in communication thread
ASIO2_ASSERT(false);
ec = asio::error::operation_not_supported;

请教一下 这个同步调用对调用线程有什么要求?

问一个语法问题

image

我想问这是什么语法template后面空格调用方法。这里的template是什么?

gcc7.2.0编译错误

/home/chenya/code/dts/./thirdparty/asio2/include/asio2/external/magic_enum.hpp: In function 'constexpr std::size_t magic_enum::detail::find(std::string_view, char)':
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/external/magic_enum.hpp:237:29: error: call to non-constexpr function 'std::basic_string_view<_CharT, _Traits>::size_type std::basic_string_view<_CharT, _Traits>::find_first_of(_CharT, std::basic_string_view<_CharT, _Traits>::size_type) const [with _CharT = char; _Traits = std::char_traits; std::basic_string_view<_CharT, Traits>::size_type = unsigned int]'
return str.find_first_of(c);
~~~~~~~~~~~~~~~~~^~~
In file included from /home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/server.hpp:33:0,
from /home/chenya/code/dts/./thirdparty/asio2/include/asio2/tcp/tcp_server.hpp:20,
from /home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/ws_server.hpp:20,
from /home/chenya/code/dts/./thirdparty/asio2/include/asio2/websocket/ws_server.hpp:11,
from /home/chenya/code/dts/src/server/ws_sdk.h:11,
from /home/chenya/code/dts/src/main.cpp:3:
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp: At global scope:
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:48:56: error: template argument 1 is invalid
std::declval<std::decay_t>()->io_context()), void>> : std::true_type {};
^

/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:48:66: error: template argument 2 is invalid
std::declval<std::decay_t>()->~io_context()), void>> : std::true_type {};
^~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:55:55: error: template argument 1 is invalid
std::declval<std::decay_t>().io_context()), void>> : std::true_type {};
^

/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:55:65: error: template argument 2 is invalid
std::declval<std::decay_t>().~io_context()), void>> : std::true_type {};
^~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:64:67: error: template argument 1 is invalid
(std::declval<std::decay_t>())->executor_work_guard()), void>> : std::true_type {};
^

/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:64:77: error: template argument 2 is invalid
(std::declval<std::decay_t>())->~executor_work_guard()), void>> : std::true_type {};
^~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:71:66: error: template argument 1 is invalid
(std::declval<std::decay_t>()).executor_work_guard()), void>> : std::true_type {};
^

/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:71:76: error: template argument 2 is invalid
(std::declval<std::decay_t>()).~executor_work_guard()), void>> : std::true_type {};
^~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:75:2: error: static assertion failed
static_assert(is_io_context_pointer<asio::io_context* >::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:76:2: error: static assertion failed
static_assert(is_io_context_pointer<asio::io_context*& >::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:77:2: error: static assertion failed
static_assert(is_io_context_pointerasio::io_context*&&::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:78:2: error: static assertion failed
static_assert(is_io_context_pointer<std::shared_ptrasio::io_context >::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:79:2: error: static assertion failed
static_assert(is_io_context_pointer<std::shared_ptrasio::io_context& >::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:80:2: error: static assertion failed
static_assert(is_io_context_pointer<std::shared_ptrasio::io_context&&>::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:81:2: error: static assertion failed
static_assert(is_io_context_pointer<std::shared_ptrasio::io_contextconst&>::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:82:2: error: static assertion failed
static_assert(is_io_context_object<asio::io_context >::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:83:2: error: static assertion failed
static_assert(is_io_context_object<asio::io_context& >::value);
^~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/base/iopool.hpp:84:2: error: static assertion failed
static_assert(is_io_context_objectasio::io_context&&::value);
^~~~~~~~~~~~~
In file included from /home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/impl/ws_send_op.hpp:29:0,
from /home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/ws_session.hpp:22,
from /home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/ws_server.hpp:21,
from /home/chenya/code/dts/./thirdparty/asio2/include/asio2/websocket/ws_server.hpp:11,
from /home/chenya/code/dts/src/server/ws_sdk.h:11,
from /home/chenya/code/dts/src/main.cpp:3:
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:256:40: error: 'set_root_directory' declared as an 'inline' field
inline self& set_root_directory(std::filesystem::path path)
^~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:256:16: error: expected ';' at end of member declaration
inline self& set_root_directory(std::filesystem::path path)
^~~~~~~~~~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:256:40: error: 'std::filesystem' has not been declared
inline self& set_root_directory(std::filesystem::path path)
^~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:256:57: error: expected ')' before 'path'
inline self& set_root_directory(std::filesystem::path path)
^~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:265:21: error: 'filesystem' in namespace 'std' does not name a type
inline const std::filesystem::path& get_root_directory() noexcept
^~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:347:31: error: 'fill_file' declared as an 'inline' field
inline self& fill_file(std::filesystem::path path,
^~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:347:16: error: expected ';' at end of member declaration
inline self& fill_file(std::filesystem::path path,
^~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:347:31: error: 'std::filesystem' has not been declared
inline self& fill_file(std::filesystem::path path,
^~~~~~~~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:347:48: error: expected ')' before 'path'
inline self& fill_file(std::filesystem::path path,
^~~~
/home/chenya/code/dts/./thirdparty/asio2/include/asio2/http/response.hpp:419:8: error: 'filesystem' in namespace 'std' does not name a type
std::filesystem::path root_directory
= std::filesystem::current_path();
^~~~~~~~~~

我在网上搜索了相关问题,filesystem 在gcc8.0以下版本位置在这里
#include<experimental/filesystem>

为什么叫asio2

看简介,这是一个基于asio的网络框架,相比asio提供了更多的工具方便使用,但是名字叫asio2给人一种asio升级版的意思,这会不会让人误解?

应用层接口是否能支持手动选择阻塞/非阻塞方式发送?

例如KCP客户端通过timer定时发送心跳包(附带时间戳),服务端以此统计延迟。
我这边本地测试出来延迟上百ms,感觉阻塞在内部了?

有些数据包优先级比较高需要立即发送,接口层面上应该有所支持。
例如kcp,当选择阻塞发送时,ikcp_update应该立即进行一次刷新。

Android下编译错误

使用Android Studio集成JNI工程时,beast/core/detail/config.hpp:36 检测到__GNUC__版本过低,这个有解决办法吗?NDK版本 21.4.7075529

在平板上发送消息延迟严重

凌动处理器的平板。循环调用async_send发送消息,延迟很大,开始是两三秒,很快就是延迟3、4分钟。同样的代码在笔记本电脑上就没有这么大延迟,保持在3、4秒钟左右。请问是什么原因?是平板性能跟不上?

可能的头文件冲突问题

假设, 我有一个项目, 其同样需要使用fmt, spdlog, json等库, 且这些库的版本比当前所使用的版本更新.
那么我们需要做什么以规避可能会出现的头文件冲突问题?
有这个疑问是因为我看include/external/json里面是直接用了那个single header, 但假设我所在的项目也有这个single header, 那么是否会直接出现编译错误?

android gcc无法编译

报错出现在:
\beast\core\detail\config.hpp:36:4: error: Beast requires C++11: gcc version 4.8 or later needed

检查Android ndk版本,gcc为4.9.

更换nkd版本,并手动指定gcc版本为4.9同样报这个错误。

C# .net core compatible library for RCP

Hello,

I need to use RPC is my c++ client, however, for server-side application I have to use C# .net core.
do you know of any compatible C# server library with asio2?

thanks

能否提供ws服务首次应答后的通知或回调或手动应答

我使用

server.bind("/ws", websocket::listener<asio2::http_session>{}.
	on("message", [](std::shared_ptr<asio2::http_session>& session_ptr, std::string_view data)
{

方式创建ws服务,功能上需要ws客户端链接后ws服务应答后的通知,服务再处理业务,看了代码没有找到这种回调接口。

问题不是问题

首先,惊人的项目! 你值得高度赞扬。

其次,正如标题所说,这与其说是问题,不如说是一个问题。 我一直在网上追逐很多东西,试图重现这样的东西:https://forum.qt.io/topic/138023/reproduce-windows-iocp-server 但是到目前为止没有成功。

你认为我可以用你的图书馆复制上述内容吗? 从您的示例的初步检查来看,这似乎是可能的。 然而,一些需要的东西对我来说仍然是个问题。

非常感谢您的帮助!

quic

The quic protocol may be a more attractive protocol for reliable udp transmisison. Of cource, the quic implementation is daunting in consideration of the large size of its codebase. But there is an alternative option implemeted by facebook https://github.com/facebookincubator/mvfst/tree/master/quic.
The most important fature is the newer congestion control algorithm BBR.
Just a suggesstion. The author can try it.

read error found

tcp client接收消息的时候出现“read error found”提示,请问是什么原因导致的呢?

rpc client 使用 local_endpoint(...) 后,无法重新绑定端口

第一次Startup(...)会成功,Shutdown()后,再次使用相同的参数Startup会报错,如不调用local_endpoint(...),目前来看没什么问题,但是请问该如何设置本地端口?

    p_bool RpcTerminal::Startup(const p_string& host, const p_string& port, const p_string& local_port)
    {
        if (rpc_client_ == p_nullptr)
        {
            rpc_client_ = std::make_unique<asio2::rpc_client>();
        }

        rpc_client_->default_timeout(std::chrono::seconds(kDefaultRpcClientCallTimeoutInSec));

        if (rpc_client_->is_started())
        {
            return true;
        }

        rpc_client_->local_endpoint(asio::ip::tcp::v4(), atoi(local_port.c_str()));

        //TODO: Implement the callbacks.
        rpc_client_->bind_connect([&](asio::error_code ec) {})
            ;

        return rpc_client_->start(host, port);
    }

    void RpcTerminal::Shutdown()
    {
        if (rpc_client_ != p_nullptr)
        {
            rpc_client_->stop();
            rpc_client_ = p_nullptr;
        }
    }

always got 404 page on http requirement

on test demo ssl_http_client line 40
auto reprss = asio2::https_client::execute("https://github.com/freefq/free", std::chrono::seconds(60));
always got a 404 page

the reason is we suppose to ack a requirement to link https://github.com/freefq/free but execute function result is sending a https://github.com/freefq%2Ffree requirement
my chrome browse got right result by https://github.com/freefq/free also failed 404 page by https://github.com/freefq%2Ffree

reason on code:
on file http_util.hpp line 231 to line 241 percent encoding all remaining url
here is my thoughts:
i think one symbol need percent encoding is to avoid conflicting with its real meaning
a link is like a filesystem,symbol '/' mean levels
suppose github.com/freefq/free to C:/test/scene1
change C:/test/scene1 to C:/test%2Fscene1 outcome is not a valid address
the scene percent encoding can make sense is the folder name with a ‘/’ inside
so we assume 'sce/ne1' is a folder name then percent encoding it change to C:/test/sce%2Fne1
percent encoding on url should be a user initiate behavior so the first paramter should fill with a url already percent-encoded by user when using asio2::https_client::execute

and now my solve is simpling block percent encoding on file http_util.hpp line 231 to line 241
from
if (/*std::isalnum(c) || */unreserved_char[c])
{
r += static_cast<rvalue_type>(c);
}
else
{
r += static_cast<rvalue_type>('%');
rvalue_type h = rvalue_type(c >> 4);
r += h > rvalue_type(9) ? rvalue_type(h + 55) : rvalue_type(h + 48);
rvalue_type l = rvalue_type(c % 16);
r += l > rvalue_type(9) ? rvalue_type(l + 55) : rvalue_type(l + 48);
}
to
r += static_cast<rvalue_type>(c);
and got the correct page result
i dont konw is correct or not or may cause other error on some scene

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.