zhllxt / asio2

Header only c++ network library, based on asio,support tcp,udp,http,websocket,rpc,ssl,icmp,serial_port,socks5.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

udp 怎样获取应答数据?

uvwz opened this issue · comments

commented

udp client 通过 send 发送消息后
怎样在当前线程获取server端对该消息返回的数据?

这个是异步框架,不支持这个功能。
接收数据只能在bind_recv的回调函数中去获取。

commented

rpc 框架里面可以添加udp方式吗?

asio2::rdc::option rdc_option
{
	[](std::string_view)
	{
		return 0;
	}
};

asio2::udp_client client;

client.start("ip", port, rdc_option);

std::string response = client.call<std::string>("some message");

关于这个用法的具体说明可以参考:asio2/doc/blog/zh-cn/rdc.md

commented

很强大的框架,非常感谢。