CSocket和MFC编程 [英] CSocket and MFC programming
问题描述
我正在编写有关一个系统的代码,该系统由处理多个客户端连接的服务器组成.
https://docs.google.com/drawings/d/1IeZBO9jqxbXCZPvX6A3C hl = zh_CN
上面的链接是有关其工作原理的简要介绍.
在服务器中,我使用CDocument派生的类来管理套接字对象和数据,因为我的计算机具有多个网络适配器,所以我需要一个链接列表来管理服务器侦听套接字.
我没有初始化套接字到不同适配器的问题.但是我遇到了将连接请求传递到客户端套接字列表的问题.我可以重写通知函数(例如OnRecieve,OnAccept),但是我不知道如何将套接字中的操作(例如,使用接收到的数据更改文档类的数据)返回文档类. >
我正在Windows 7 Ultimate上使用VS2010.
非常感谢.
I''m writing code about a system that consist of a server handling multiple client connection.
https://docs.google.com/drawings/d/1IeZBO9jqxbXcZPvX6bsAjcM8O3L9KJW7C8UVELa-jUM/edit?hl=en_US
The link above is the image about the brief idea of how it works.
In the server I use a CDocument-derived class to manage the socket objects and data, as my computer has multiple network adapters, I need a link list to manage the server listening sockets.
I''ve got no problem of initializing the sockets to different adapters. But I have encounter a problem of passing the connection request to Client Socket list. I can override the Notification Functions(e.g. OnRecieve, OnAccept) but I don''t know how to refer the action in the socket(for example changing the data of document class with the data received) back to the document class.
I''m using VS2010 on Windows 7 Ultimate.
Thank you very much.
推荐答案
您的套接字类需要成员HWND才能发布(不发送)用户向主窗口发送消息,提示数据已更新.他们可以处理数据吗?
我强烈建议您划分套接字,文档和视图.不要编写意粉代码,您会后悔的!!!
your socket class needs a member HWND to post (not send) user messages to the main Window that data is updated. Their can you process the data.
I strongly recommand you to divide your socket, document and view. Dont write spaghetti code you will regret it!!!
这篇关于CSocket和MFC编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!