|
Hi,
I have a derived CAsyncSoct class as a member of a Derived CwinThread Class
the members that I have in my derived CAsynSocket class include data members such as a port no
that I wish to connect to
so...
class CSocketThread : public CwinThread
{
public
CSocket thisicket
}
class CSocket : public CAsynSocket
{
I create a UI thread
via new SockThread(start_port)
I create the thread suspended
fill in the missing pieces such the ipaddr, port #
Then do a resumethread this should kick the SockThread:Iinitinstance overridable
I figure by this time everthing the SockThread and Csocket Objects has been Created
So in the SOckThread::initinstance I do a Socket.create withe yhe ipaddr and port
By the time i get to create the third of fourth thread I get an exceptin from
CAsynSocket::Create
One of my questons is if I create the SockThread on the heap via new does that mean
every data memeber and or classes such the CSocket is contructed on the heap
and is there something wrong with my design
Thanks in advance
|
|
|
|
|
First of all, without synchronisation objects, you can't rely on anything having happened in another thread.
Second, CAsynchSocket has some inherent design problems (see CSocket considered harmful). You might want to consider rolling your own using the Win32 SDK if you're going to keep it running in a separate thread.
Third, you shouldn't create your CWinThread object directly. Use AfxBeginThread instead.
|
|
|
|
|
Thank you for response youe point about synchronistion is well taken
Second I am creating a UI thread as I want the send/receive socket to be initiate dvia messages and I dont beleive the owrker threads can process messages
I didn't know there were porblems with CSocket
Thank you
|
|
|
|