|
-
March 25th, 2004, 09:07 AM
#1
How to work with CAsyncSocket in multitasking environment?
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
-
March 25th, 2004, 10:19 AM
#2
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.
-
March 25th, 2004, 10:22 AM
#3
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.
-
March 25th, 2004, 10:38 AM
#4
-
March 26th, 2004, 03:59 AM
#5
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.
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
|