asio 同步 RuntimeError
【摘要】
c++:
static tcp::socket *g_socket;int send_msg_async(void* conn, const char* data, int len) { tcp::socket * client = (tcp::socket*)g_socket; printf("start send %s\n", data); asio...
c++:
-
static tcp::socket *g_socket;
-
int send_msg_async(void* conn, const char* data, int len) {
-
tcp::socket * client = (tcp::socket*)g_socket;
-
printf("start send %s\n", data);
-
-
-
asio::write(*client, asio::buffer("data", 4));
-
-
/*std::size_t request_length = 0;
-
request_length = std::strlen(data);
-
asio::write(client->socket_, asio::buffer(data, request_length));
-
printf("send end %s\n", data);*/
-
return 0;
-
}
-
-
-
void * start_conn_async(py::function call_back) {
-
-
std::string host = "127.0.0.1";
-
std::string port = "5200";
-
enum { BUF_SIZE = 1024 };
-
-
asio::io_context io_context;
-
-
// NOTE:
-
// Don't use output parameter |error_code| in this example.
-
// Using exception handling could largely simplify the source code.
-
try {
-
tcp::resolver resolver(io_context);
-
-
// Return type: tcp::resolver::results_type
-
auto endpoints = resolver.resolve(
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/89458099
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)