title: Exception when writing to socket: Unable to write data to transport connection
body: <p>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:</p>
  
  <p>The connection is closed from one thread when the remote client asks, in this exact moment the write operation throws this exception:</p>
  
  <blockquote>
    <p>unable to write data to transport connection: a blocking operation was interrupted by a call to WSACancelblockingcall</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>Any suggestions? is this a hardware problem? is this a TCP protocol problem? any one had a similar problem and had found a solution?</p>
  
  <p>EDIT:</p>
  
  <p>pseudo code to illustrate the issue:</p>
  
  <p>First thread:</p>
  
  <pre><code>while(true)
  {
       if (some condition)
               close connection;
  }
  </code></pre>
  
  <p>second thread:</p>
  
  <pre><code>while(true)
  {
        sleep for 20 minutes
        write(array of 64 bytes) //blocks for a very long period of time
  }
  </code></pre>