Hi guys, I'm trying to code a wrapper for asynchronous WinSock...
What I have planned out so far:Is this a feasible way to write a sockets wrapper? Personally, I think this way is sort of clumsy, but I can't think of anything else. Any ideas? Input? My goal is to keep my wrapper class as a "Plug 'n Play" code module sort of thing, while still providing easy functionality. Does anyone have a better way of doing this, or does my plan sound O.K.?-function 'startup()' (in namespace 'Sockets') calls WSAStartup() and also starts a new thread
-when the thread starts, it creates a new invisible window (for messages), the handle of which gets stored as a static variable
-The thread starts up a GetMessage() loop
-Any new ASocket will call WSAAsyncSelect using the invisible window's handle, and will add an entry to a static std::map container using its SOCKET descriptor as the key and a pointer to itself as the value. Also, it will be passed a HWND as a parameter, which will be stored for later use.
-The message handler for the socket messages uses the static std::map to find the appropriate ASocket object and set its 'readable', 'writable', etc. variables to true. After this, it re-posts the message to the HWND stored in the object earlier, in case the user wants to handle the message him/herself as well.
P.S. I posted on the Windows forum because of the stuff about threads and windows, etc. and also because nobody ever replies on the networking forum![]()



LinkBack URL
About LinkBacks



