[background] a member of the socket is a thread, the thread of the destructor, close the socket, delete the socket
[the original code logic]
1. The thread received killThread SetEvent (m_killevent) events, then enter the InitInstance - & gt; ExitInstance, thus the end of the thread,
2. And then other call, will call the delete pthread threads to the destructor, then close the socket, delete the socket,
[now code logic]
1. The thread to read message processing mode, and received killThread KILL_THREAD news is now sent PreTranslateMessage, after it received, will invoke the API: ExitThread.
2. The other call, will call the delete pthread threads to the destructor, then close the socket, delete the socket, these haven't changed, or the original logic,
[question] code instead of logic, now close socket, throw exceptions, closed to determine whether a socket is NULL, not NULL, just shut down, after the delete socket, socket - & gt; Close () when abnormal,
[for]
1. The socket - & gt; Throw exceptions, close with CException class didn't catch exceptions, which interface to capture anomalies can call? See the specific error types,
2. The socket - & gt; The close commented out, also not line, can be in the delete the socket exceptions,
3. ExitThread this API interface is wrong? What can call interface? Then other call point or invoke delete pthread unchanged,
4. According to the logic of the code, now ExitThread - & gt; Delete the pthread wrong?
5. What is the positioning means?
CodePudding user response:
PS:In the code to invoke the delete two pthread place, only a place to delete the inside of the pthread socket - & gt; There is something wrong with the close, another problem,
CodePudding user response:
PS:InitInstance PreTranslateMessage instead:
1. Because there is a thread, I want to post a message to the thread, the thread in order to receives the message, so I changed the interface to PreTranslateMessage
CodePudding user response:
Multiple Threads in the User Interface of http://msdn.microsoft.com/zh-cn/library/ms810439.aspx"Windows core programming"
CodePudding user response:
Message received, but haven't execute close the Socket - & gt; Close(); The main thread to exit, then the child thread also dropped out, cause a memory leak, so need Waitforsigleobject function waiting Socket were closed, and then the child thread exit.CodePudding user response:
The socket - & gt; Debugging and running, the close setting a breakpoint, the suspicions of the delete many timesCodePudding user response: