有个试题, 帮忙给点思路,谢谢

jimmyzheng173 2008-07-18 04:58:44

1. Here is the situation:
I. There is an incoming streaming of data thru TCP/IP in raw format
II. You need to process these data into a user defined format
III. There are clients that randomly connect/disconnect to/from you
IV. You need to relay the processed data to all the clients connecting to you
V. You need to have a GUI showing how much data is processed and which client is connected.

Draw a simple design diagram showing:
• How to achieve the above and specify what data type is used
• If thread is used, show where thread-safe techniques should be implemented
• Explain what kind of networking protocol/techniques is used at different places and why choose such implementation

Explain why and how you come up with this design and what the pros and cons are.
...全文
140 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
vcPlayer 2008-07-20
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 k66k 的回复:]
引用 7 楼 vcPlayer 的回复:
raw tcp socket 就是你收到的数据都是协议数据包,而仅非我们平常所说的“内容”——有效负责。

创建socket的时候有一个参数就可以创建这种RAW SOCKET。收回来的数据自己按照协议格式解析就行了。


服务端收到的"协议数据包" 如何判断是那个客户端的, 各个客户端又是如何标识的, 转发的时候是总要知道目的地到底在哪里 ,
[/Quote]

[Quote=引用 9 楼 jiangsheng 的回复:]
包格式都在TCP/IP协议里面啊
[/Quote]

网络通信中是以IP地址来定位计算机的,计算机中的程序是用端口来定位的。知道这两个元素就可以定位客户端。而这两个元素就在IP数据报中。协议文本到处都有,关键是自己要“能动”的去看。实在不明白可以装个Sniffer软件,抓个包来对比分析就一目了然的!
蒋晟 2008-07-20
  • 打赏
  • 举报
回复
包格式都在TCP/IP协议里面啊
vcPlayer 2008-07-19
  • 打赏
  • 举报
回复
raw tcp socket 就是你收到的数据都是协议数据包,而仅非我们平常所说的“内容”——有效负责。

创建socket的时候有一个参数就可以创建这种RAW SOCKET。收回来的数据自己按照协议格式解析就行了。
蒋晟 2008-07-19
  • 打赏
  • 举报
回复
作业自己做,抄袭是不好的行为
jimmyzheng173 2008-07-19
  • 打赏
  • 举报
回复
其实并不是作业, 只是看到了,对raw tcp socket 的相关感兴趣,又苦于找不到好的资料,故向大家请教而已罢了
jimmyzheng173 2008-07-19
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 vcPlayer 的回复:]
raw tcp socket 就是你收到的数据都是协议数据包,而仅非我们平常所说的“内容”——有效负责。

创建socket的时候有一个参数就可以创建这种RAW SOCKET。收回来的数据自己按照协议格式解析就行了。
[/Quote]

服务端收到的"协议数据包" 如何判断是那个客户端的, 各个客户端又是如何标识的, 转发的时候是总要知道目的地到底在哪里 ,
9527他大爷 2008-07-18
  • 打赏
  • 举报
回复
看不明白,帮顶
luohongming 2008-07-18
  • 打赏
  • 举报
回复
看不明白,帮顶
vcPlayer 2008-07-18
  • 打赏
  • 举报
回复
[Quote=引用楼主 k66k 的帖子:]

1. Here is the situation:
I. There is an incoming streaming of data thru TCP/IP in raw format
II. You need to process these data into a user defined format
III. There are clients that randomly connect/disconnect to/from you
IV. You need to relay the processed data to all the clients connecting to you
V. You need to have a GUI showing how much data is processed and which client is con…
[/Quote]

LZ看懂了吗?一个基本的服务端程序设计,不是很难吧?当然,要做得很好还是有挑战性的。

抛砖引玉:
线程大概有:接收、解析、转发、处理连接的监听线程及界面线程;

数据结构大致有:
数据缓冲区(接收、解析、转发访问)、
客户端地址列表,可用STL(连接、转发线程访问)、
常用的网络通信协议结构…………

并发访问的地方注意数据同步处理
scq2099yt 2008-07-18
  • 打赏
  • 举报
回复
up

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧