How can I avoid "Socket Notification Sink" error?
-
when I try to "restart system" or "turn off system" , I get error message "Socket Notification Sink" Dialog box. And it didn't work reboot or turn off.. How can I avoid "Socket Notification Sink" error? My main brief code as followings.
/* tread will do send something infinitely with 5 second sleep unless it is ended*/ UINT _ThreadDoSomethingInfinite(LPVOID pParam) { char buf[100]; CSocket h_sock; CMyDlg *p=(CMyDlg*)pParam; h_sock.Create( nPort , SOCK_DGRAM); while(1) { Sleep(5000); . . stcpy(buf, "some data..buffering.."); h_sock.SendTo( buf , 1234 , "127.0.0.1" ); } //will never reach... h_sock.ShutDown(2); h_sock.Close(); } CWinThread g_updsock; BOOL CMyDlg::OnInitDialog() g_updsock=AfxBeginThread(_ThreadSendAgentStatus,this,THREAD_PRIORITY_NORMAL); if(g_updsock==NULL) return; }
-
when I try to "restart system" or "turn off system" , I get error message "Socket Notification Sink" Dialog box. And it didn't work reboot or turn off.. How can I avoid "Socket Notification Sink" error? My main brief code as followings.
/* tread will do send something infinitely with 5 second sleep unless it is ended*/ UINT _ThreadDoSomethingInfinite(LPVOID pParam) { char buf[100]; CSocket h_sock; CMyDlg *p=(CMyDlg*)pParam; h_sock.Create( nPort , SOCK_DGRAM); while(1) { Sleep(5000); . . stcpy(buf, "some data..buffering.."); h_sock.SendTo( buf , 1234 , "127.0.0.1" ); } //will never reach... h_sock.ShutDown(2); h_sock.Close(); } CWinThread g_updsock; BOOL CMyDlg::OnInitDialog() g_updsock=AfxBeginThread(_ThreadSendAgentStatus,this,THREAD_PRIORITY_NORMAL); if(g_updsock==NULL) return; }
Hi, I suggest to exit the endless loop when the application is signaled to terminate or an error occured. Add basic error handling to the socket methods, e.g.
Create
andSendTo
return a status. Alternatively use a different socket class than MFC'sCSocket
or use plain sockets (Winsock). /MWebchat in Europe :java: (only 4K)