客户端处理多个套接字连接的IO模型 [英] IO model for client handling multiple socket connection

查看:89
本文介绍了客户端处理多个套接字连接的IO模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C ++(Windows和Linux)上的TCP客户端模拟器.这里可以模拟1000个客户端.每个客户端都有一些服务器可能需要的状态信息.服务器可以通过发出带有客户端ID的命令来获取特定客户端的状态.

服务器可能发出这些命令
1.开始流"将数据连续流传输到服务器.
2.停止流"-停止流
3.状态"-要求状态

客户回应
1.流数据
2.停止流式播放
3.将状态信息发送到服务器.


我们不能使用第三方库(boost等)来做到这一点.我需要用C ++实现.我遇到了多个I/O模型,例如Completion Port,Overlapped I/O等.我很困惑哪一个适合用于客户端应用程序.

1.我想知道哪种I/O模型适合客户端管理这些数字实例.

2.如何确保每个客户端实例的状态.
3.维护每个客户端状态信息的数据结构.

I am working on TCP Client Simulator on C++(windows and Linux).Here can simulate 1000 client.each client has some status information which server may require.Server can get the status of a particular client by issuing command with client ID.

Server may issue these command
1."start-stream"-streams the data to server continually.
2."stop stream"-stops the streaming
3."Status"-asking for status

client respond with
1.streams the data
2.stops the streaming
3.send status information to server.


We can''t use third party libraries(boost etc) to do this.I need to implement in C++.I came across the Several I/O model like Completion Port,Overlapped I/O etc.I am confused which one will suitable for the client application.

1.I wanted to know what I/O model is suitable for Client to manage these number instance.

2. how can I ensure the state of the each client instance.
3. data structure to maintain the status information of the each client.

推荐答案

如果您不能使用开放源代码库-如ACE [ ^ ],您显然必须使用自己的替代方法.
查阅POSA2本书,并行对象和联网对象的模式 [
If you can''t use open source libraries - like ACE[^], you obviously have to roll your own alternative.
Check out the POSA2 book, Patterns for Concurrent and Networked Objects[^]

Patterns are recipes on how to implement functional software based on successful implementations.

Best regards
Espen Harlinn


lok.vikram,通过此链接,我认为这对您有所帮助


具有多个客户端的单个服务器:简单的C ++实现 [
Hi, lok.vikram ,go through this link i think this will help u


Single Server With Multiple Clients : a Simple C++ Implementation[^]


嗨lok.vikram,请通过此链接进行操作我认为这对您有帮助

www.madwizard.org/programming/tutorials/netcpp/5
hi lok.vikram,go through this link i think this will help u

www.madwizard.org/programming/tutorials/netcpp/5


这篇关于客户端处理多个套接字连接的IO模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆