Click to See Complete Forum and Search --> : How to work with CAsyncSocket in multitasking environment?
Dilshod Nabishev
March 25th, 2004, 08:07 AM
I'v created CAsyncSocket object and connected it in main thread. I started "watchdog" thread and in the case of broken connection i want to reconnect. All operations in "watchdog" result in unhandled exception, but the object is correct. May be threre is some rule in working with CAsyncSocket object from other thread?
Thanks
darwen
March 25th, 2004, 09:19 AM
This is about the 50th time that this question has come up in the last month so once again.....
You can't pass most objects derived from CObject around between threads. You'll have to do some kind of message passing instead.
You certainly can't do CWnd and derived classes and I bet you can't do CAsyncSocket either.
Darwen.
darwen
March 25th, 2004, 09:22 AM
However, you can create your own sockets using WinSock and pass their handles around between threads which is what I always do.
CAsyncSocket (again for the 50th time) is a bit rubbish to be honest and isn't reliable at all.
Darwen.
Andreas Masur
March 25th, 2004, 09:38 AM
[Moved thread]
Pham Son Thuy
March 26th, 2004, 02:59 AM
If socket S was created by thread A, then the socket S must also be closed by thread A. It would crashed it thread B trying to close S.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.