Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

tcpclient

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?

like image 560
Len Smith Avatar asked Sep 13 '25 06:09

Len Smith


2 Answers

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.

like image 159
mslot Avatar answered Sep 17 '25 19:09

mslot


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
like image 28
Adil Avatar answered Sep 17 '25 20:09

Adil