CAsynSocket Client Question
-
Hi I want to connect a number of sockets (2 or 3) on a port seems like the underlying Object of CAsynSocket is m_hSocket. That would lead me to believe that on the Client Side for Every Client m_hSocket I would have to instantiate a CAsnycSocket class via new (on the heap) and do a Create and later connect ? It seems after the Create m_hSocket would have a value am I correct on this ? Thanks
-
Hi I want to connect a number of sockets (2 or 3) on a port seems like the underlying Object of CAsynSocket is m_hSocket. That would lead me to believe that on the Client Side for Every Client m_hSocket I would have to instantiate a CAsnycSocket class via new (on the heap) and do a Create and later connect ? It seems after the Create m_hSocket would have a value am I correct on this ? Thanks
It's not completely clear what you're asking, but I can say that
m_hSocket
is the underlying SOCKET handle that theCAsyncSocket
object encapsulates. You are able to create a new CAsyncSocket object and then attach an existing SOCKET handle by using the Attach() method.The difficult we do right away... ...the impossible takes slightly longer.
-
It's not completely clear what you're asking, but I can say that
m_hSocket
is the underlying SOCKET handle that theCAsyncSocket
object encapsulates. You are able to create a new CAsyncSocket object and then attach an existing SOCKET handle by using the Attach() method.The difficult we do right away... ...the impossible takes slightly longer.
Yes that's what I was looking for so if I want to use 2 Different sockets I have to have two instances of CAsynSocket In Addition If a wrapping CasynSockets in CWinThread Class when getting the OnConnect Notifcation Its is in The Context of the Main Thread so I would have to take that (Main Threads) m_hScoket and Attach to the one used by my CwinThread ? correct As I believe all CasynSocket notification are in the Context of the Main Thread Thanks
-
Hi I want to connect a number of sockets (2 or 3) on a port seems like the underlying Object of CAsynSocket is m_hSocket. That would lead me to believe that on the Client Side for Every Client m_hSocket I would have to instantiate a CAsnycSocket class via new (on the heap) and do a Create and later connect ? It seems after the Create m_hSocket would have a value am I correct on this ? Thanks
You may want to read this great Joe Newcommer essay: [An MFC Asynchronous Socket Example Done Right](http://www.flounder.com/kb192570.htm)