设为首页 加入收藏

TOP

C++ ASIO 实现异步套接字管理(三)
2023-09-09 10:25:48 】 浏览:384
Tags:ASIO 步套接 管理
; << tcpServer.GetRemoteAddress(tcp_client_id[x]) << " \t " << tcpServer.GetRemotePort(tcp_client_id[x]) << std::endl; } PrintLine(80); } // 解析 [shell] # GetCPU --id 100 if (vecSegTag.size() == 3 && vecSegTag[0] == "GetCPU") { char *id = (char *)vecSegTag[2].c_str(); send_message(tcpServer, atoi(id), "GetCPU", strlen("GetCPU")); } // 解析 [shell] # GetMemory --id 100 if (vecSegTag.size() == 3 && vecSegTag[0] == "GetMemory") { char* id = (char*)vecSegTag[2].c_str(); send_message(tcpServer, atoi(id), "GetMEM", strlen("GetMEM")); } // 解析 [shell] # Exit --id 100 if (vecSegTag.size() == 3 && vecSegTag[0] == "Exit") { char* id = (char*)vecSegTag[2].c_str(); send_message(tcpServer, atoi(id), "Exit", strlen("Exit")); } } } return 0; }

案例演示

首先运行服务端程序,接着运行多个客户端,即可实现自动上线;

当用户需要通信时,只需要指定id序号到指定的Socket套接字编号即可;

本文作者: 王瑞
本文链接: https://www.lyshark.com/post/d0805aed.html
版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

首页 上一页 1 2 3 4 5 6 下一页 尾页 3/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Pybind11绑定C++抽象类(DLL接口) 下一篇AC 自动机学习笔记

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目