I am developing a client server application using sockets in C#, It is a multi Threading application for sure, the strange thing is the following:
The connection is closed from one thread when the remote client asks, in this exact moment the write operation throws this exception:
unable to write data to transport connection: a blocking operation was interrupted by a call to WSACancelblockingcall
Actually I am writing 64 byte each 20 minutes, but the strange thing is that the above exception is thrown each time the connection is closed, that means the write operation is taking very very long time to complete to the extend that the operation is always stopped by the connection close, is this a problem in the network stack?, The more strange thing is that this problem happens only with one client, and still happening for more than a week,so it is not temporary.
Any suggestions? is this a hardware problem? is this a TCP protocol problem? any one had a similar problem and had found a solution?
EDIT:
pseudo code to illustrate the issue:
First thread:
while(true)
{
if (some condition)
close connection;
}
second thread:
while(true)
{
sleep for 20 minutes
write(array of 64 bytes) //blocks for a very long period of time
}