开发者

CSocket programming

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.


You should not create CSocket directly, but derive a class

CMySocket : CSocket {
   CDocument *m_doc; // or CDocument &m_doc;
}

Then never create a CSocket but always your CMySocket with m_doc set to your document. That way you can access the document from socket.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜