我时常碰到这个错误, 没有什么办法可以解决, 看来是MFC的先天不足, 这是网络上唯一一篇有关人员的解决方法, 不知道本论坛上的中国网络高手有什么独到见地, 欢迎贡献!HELP: Socket Notification Sink Error Being Generated By Windows
 SYMPTOMS
Windows randomly generates a "Socket Notification Sink" error and aborts the program or waits to shutdown the computer. CAUSE
There is not a lot of specific information available as to why Window's will sometimes generate this error so we will relate our personal experience concerning this event.  Individuals finding additional information concerning this matter can forward the information to [email protected] so that we can update this record.In our experience, this error can be generated by utilizing sockets in secondary threads and is more commonly seen in threads invoked by applications running as Window's services.  This error is typically generated by the secondary thread when creating or attaching socket handles to a socket class object while more than one process is engaging in network communications at the same time.More specifically, the "Socket Notification Sink" error actually relates to a failed window creation for use by a MFC socket class object.  Since the MFC socket classes actually create and utilize a window to control the MFC socket object, failure to generate this window results in a detrimental application error.  This windows generation failure is more commonly seen in Window's services since they typically have restricted UI creation rights (even if the service has the "interact with desktop" attribute). RESOLUTION: Programmers
To date, the only resolutions to this problem have been the following:Rewrite the application/thread/service so that it only opens a socket at the beginning of execution.  The more times you create or even bind a socket, the greater the chance you will have of generating this error. 
Rewrite the application to utilize the socket layer directly and remove all instances of the MFC derived socket classes. 
Recompile your application using VC.NET. Apteryx has received reports that recompiling the project under VC.NET has helped correct the problem with MFC derived socket classes (thanks Ramasubramanian J). 
 RESOLUTION: computer users
To date, there have been several steps that have reduce the frequency of the error or have eliminated it altogether. The following steps are ordered in the frequency in which they seem to have corrected the sink error. Please note that that several of the following steps are advanced and may result in creating problems if performed by users not skilled at working with computers. Apteryx takes absolutely no responsibility for any problems that may result by following the advice presented in this documentation.Update the application or service that is generating the error. Depending on how the sink error is generated, you may or may not be able to determine which application or service generated the problem. 
If the previous step does not correct the error (of the application/service could not be determined) then update your computer's NIC device drivers and any other network adapter drivers you may have on your computer (be sure to include any "internet service provider” software that may be active on the computer). For more information on updating device drivers, please refer to Window's online help about using the Device Manager or consult the documentation that came with your hardware. 
If the previous step does not correct the error then check the TCP/IP setup of the computer and make sure that it is installed and properly configured. 
If the previous step does not correct the error then look at the services installed and running on your computer and update as many of those as possible. These services may be located either under Computer Management or Services in your Start menu. 
If the previous step does not work: download and save the latest NIC driver updates on your computer somewhere; go into Computer Management or Device Manager and remove the NIC/network devices from the hardware list (if it asks you if you want to uninstall anything say Yes); close down and turn off your computer; physically remove your NIC/network hardware; reboot your computer; reinstall the drivers for the hardware (even though the hardware is not plugged in); shut down and turn off your computer; plug your network hardware back in; power back on your computer and follow the steps in the new hardware detected wizard. 
If all else fails, remove your current network hardware (both from the device manager and the physical hardware from the computer) and purchase a new NIC card (we recommend that you stick with a larger manufacturer). 
 

解决方案 »

  1.   

    我用casyncsocket,有的時候出現socket notification sink標題的錯誤.
    說是非法訪問內存.我查找了資料,說是mfc類的問題.
    解決方法:1用vc.net編譯
    2.自己寫socket類.可是為甚麼出現這個錯誤.還是隨機的.您知道嗎.
    謝謝您
    2004-04-29 15:25 回复 "Socket Notification Sink"是CAsyncSocket创建的一个隐含窗口的标题。该窗口的作用
    是接收异步socket发来的通知消息。在Windows下,无论我们是否基于MFC编程,使用异步
    socket时一般都需要像CAsyncSocket那样创建一个隐含窗口。你看到的标题为
    "Socket Notification Sink"的错误只表示错误发生在隐含窗口的消息处理代码内,但并
    不能说明该错误一定是MFC的源码引起的。下面这个页面分析了随机出现"Socket Notification Sink"错误的问题,可能和你找到的
    资料类似。但该文中的分析对象主要是和隐含窗口创建失败有关的错误(如服务程序无权
    限创建窗口等),如你所说,它给出的解决方案是升级到VC.NET或不使用MFC。http://www.apteryxware.com/dental/knowledgebase/topics/
    HELP__Socket_Notification_Sink_Error_Being_Generated_By_Windows.htm我还没有仔细看过VC6和VC.NET在此方面到底有什么差异,我不排除VC6代码有问题的可能。
    但从你的来信看,你说错误是“非法訪問內存”,我觉得这多半不是MFC本身引起的。你
    可以再看一下这个页面http://www.zone-h.com/advisories/read/id=4069该文提到,在一个叫IA Webmail server的程序里,当程序本身出现缓冲区溢出时,报出
    的错误也是"Socket Notification Sink"错误,而且是“内存非法访问”。这其实很好
    理解,如果程序中出现了内存异常(如错误的指针操作覆盖了有用的数据),那么,程
    序的流程已经无法预测,在"Socket Notification Sink"的窗口函数中报错也是十分正
    常的事情。我无法给你提供明确的解决方案,你可以试试升级到VC.NET之类的方法,但还是应当把
    更多的精力放到你自己的代码本身,看代码中是否存在内存非法访问、缓冲区溢出之类
    的问题,这些问题引发的错误往往也是随机错误。