VC:断言ASSERT(pState->m_hSocketWindow != NULL);
2011-07-01 16:52
686 查看
引用
千山暮雪 的 VC:断言ASSERT(pState->m_hSocketWindow != NULL);
CSocket断言错误:ASSERT(pState->m_hSocketWindow != NULL);
起因:在套接字处于连接或者发送状态时,试图关闭套接字,于是在这个断言语句处发生中断。
原因分析::
微软官方解释如下:http://support.microsoft.com/kb/140527/en-us
This assertion failure occurs because the CSocket object was either created or accepted in the context of another thread. The socket notification window was created in a different thread, and the m_hSocketWindow for the current thread is NULL, thus the assertion failure.
明白了,我就是跨线程使用CSocket,结果。。。。
解决方案:
As already mentioned, a CAsyncSocket object should be used only in the context of a single thread. If you need to switch the thread that is accessing a SOCKET connection with another thread, then you should use a separate CAsyncSocket object in each thread, and use the Detach and Attach functions to attach the CAsyncSocket object to the SOCKET handle in the thread that is about to use the socket. Use this sequence:
千山暮雪 的 VC:断言ASSERT(pState->m_hSocketWindow != NULL);
CSocket断言错误:ASSERT(pState->m_hSocketWindow != NULL);
起因:在套接字处于连接或者发送状态时,试图关闭套接字,于是在这个断言语句处发生中断。
原因分析::
微软官方解释如下:http://support.microsoft.com/kb/140527/en-us
This assertion failure occurs because the CSocket object was either created or accepted in the context of another thread. The socket notification window was created in a different thread, and the m_hSocketWindow for the current thread is NULL, thus the assertion failure.
明白了,我就是跨线程使用CSocket,结果。。。。
解决方案:
As already mentioned, a CAsyncSocket object should be used only in the context of a single thread. If you need to switch the thread that is accessing a SOCKET connection with another thread, then you should use a separate CAsyncSocket object in each thread, and use the Detach and Attach functions to attach the CAsyncSocket object to the SOCKET handle in the thread that is about to use the socket. Use this sequence:
1. | Use Detach() to detach the CAsyncSocket object from the SOCKET handle in the thread that is currently using the CAsyncSocket object. |
2. | Use Attach() to attach a different CAsyncSocket object to the SOCKET handle while in the context of the MFC UI thread in which you wish to begin accessing the SOCKET connection. |
相关文章推荐
- CSocket断言错误 ASSERT(pState->m_hSocketWindow != NULL);
- 多线程中遇到ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);如何解决
- 关于DockControlBar()时调试出现ASSERT(pBar->m_pDockContext != NULL);错误处
- java.lang.NullPointerException Exception details are logged in Window > Show View > Error Log 正确解决方法
- 在DOc的构造函数中得到VIew类指针引起的问题(GetActiveView()引起的Access Violation;this->GetFirstViewPosition()=NULL;ASSERT(AfxIsValidAddress(this, siz
- 1>/dev/null 2>&1的含义
- VC 6.0 采用菜单 File—>Open 打开 .dsw 工程时,VC 6.0 界面程序处于僵死状态问题解决
- iOS json解析遇到@"";@"<null>";null 处理
- Iocp Tcp Server——G-Socket1.1 Demo源码(VC & Delphi)
- Linux Shell 1>/dev/null 2>&1 含义
- vc 下可以运行在设置项Project->Settings->Debug->Program arguments填参数
- VC6 --->VC 8 线程消息
- IM聊天进阶(一)IM>openfire>mina>nio>socket复习
- “>/dev/null 2>&1” 详解
- >/dev/null 2>&1 的含义
- >/dev/null 2>&1
- LINUX cmd >/dev/null 2>&1 解释
- LINUX命令后面常见的>/DEV/NULL 和 2>&1 的含义
- Linux Shell脚本编程--(linux空设备文件和重定向)>/dev/null 2>&1
- VC与Matlab混合编程之调用动态链接库dll(C++)——<二>