|
-
November 26th, 2003, 05:38 PM
#2
Actually it won't be such a big change. You can implement your own version of CAsyncSocket with the same interface (i.e. same member functions & overrides) using Winsock. Then you'll have total control over how it works.
I'd have a class CAsyncSocket2 which is derived from CWnd, which on connection calls ::connect etc and creates a hidden window for itself. Then use ::WSAAsyncSelect to process messages and pass them to your own OnReceive/OnClose etc virtual functions.
Not too difficult I would say.
I might add I've already done this, only my stuff fires up a seperate thread to handle incoming messages using WSAEventSelect (the reason for this is because the threads are part of a pool to do receives so one machine can cope with thousands of concurrent connections without having to have thousands of windows). I also have seperate threads to do the send too just in case of blocks/can't send because receiving messages (again part of a thread pool).
Anyway for your case just using windows should be fine if you're wanting <50 connections per server.
So in conclusion, just implement all the same functions as in CAsyncSocket (i.e. Create, Send, OnReceive, OnClose etc) in your own class but use winsock instead.
Darwen.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|