Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall

谁说胖子不能爱 提交于 2019-12-01 07:12:16

问题


I am developing a client-server chat application and I have encountered the following exception when I close the client window.

Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall.

Any idea what could be the problem?


回答1:


If you call a .Close() on any of you readers or writers to the underlying stream. and try to use that reader or writer afterwards, then you will get this error.




回答2:


after all .Close(); calls, also close threads that call these readers/writers. Like in this similar code under discussion, the problem can be solved by simply adding .Abort(); in two places where .Close(); for streams are called:

            swSender.Close();
            srReceiver.Close();
            tcpServer.Close();
            thrMessaging.Abort(); // this needed to be added to solve the problem


来源:https://stackoverflow.com/questions/9587738/unable-to-read-data-from-the-transport-connection-a-blocking-operation-was-inte

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!