Repost: CSocket help needed
-
I use a CSocket derived class with a derived CWinThread class and use CArchive with it. For some yet unknown reason Send() locks after a while of running (hours). The opened socket has communication initiated from both client and server at times, if that helps. (Server sends tiny data once per second, client sends kB data occasionally, like every 10 seconds or so, plus both sides sends an ACK byte for every command) Anyway, since I cannot find the reason of the locking, I want to get around the locked state. I want to make something from the outside and would like to have an OnIdle timer reset at intervals in the CWinThread. A parent thread will check this timer and if it isn't reset in reasonable time (seconds) the parent thread will call CancelBlockingCall() on the locked socket. Now, will this work? Isn't it illegal to call the CSocket object function from another thread? :confused:
-
I use a CSocket derived class with a derived CWinThread class and use CArchive with it. For some yet unknown reason Send() locks after a while of running (hours). The opened socket has communication initiated from both client and server at times, if that helps. (Server sends tiny data once per second, client sends kB data occasionally, like every 10 seconds or so, plus both sides sends an ACK byte for every command) Anyway, since I cannot find the reason of the locking, I want to get around the locked state. I want to make something from the outside and would like to have an OnIdle timer reset at intervals in the CWinThread. A parent thread will check this timer and if it isn't reset in reasonable time (seconds) the parent thread will call CancelBlockingCall() on the locked socket. Now, will this work? Isn't it illegal to call the CSocket object function from another thread? :confused:
From my own experience CSockets simply aren't reliable enough for programs that need to run continuously. The best "workaround" is to use Winsock2 API directly. In my own project, I wrote a "wrapper" class to provide a CSocket-style interface so I didn't have to change the main code too much.
-
From my own experience CSockets simply aren't reliable enough for programs that need to run continuously. The best "workaround" is to use Winsock2 API directly. In my own project, I wrote a "wrapper" class to provide a CSocket-style interface so I didn't have to change the main code too much.
*shrug*, yes, I've read this before... if I could only understand why it's locking I think we could use CSocket. We do use it in similar applications that doesn't communicate so much.