title: Why Socket over Tcp doesn't send if I call it too much in a millisecond?
body: <p>I'm using following code</p>
  
  <pre><code>for(int i =0; i &lt; 100; i++){ 
      TcpSocket.Send(getModifiedData(MyData));
  }
  </code></pre>
  
  <p>The code is called too much, maybe one time per every tick.</p>
  
  <p>The socket is connected to my local machine(127.0.0.1) so there is no latency, pocket loss etc.<br>
  The first messages are just fine but I don't get some pockets later.</p>
  
  <p>Now if I change that code to following then all my pockets are sent and recieved!</p>
  
  <pre><code>for(int i =0; i &lt; 100; i++){ 
      Console.WriteLine("SendData &gt; " + TcpSocket.Send(getModifiedData(MyData)));
  }
  </code></pre>
  
  <p>And yes I'm pretty sure because I have tested this more than 10 times. Logging to console with <code>WriteLine</code> method fixes this issue.</p>
  
  <p>I'm totally lost with this very weird problem.  </p>
  
  <p>Note that following code helps to send more pockets than first default code posted in question.</p>
  
  <pre><code>for(int i =0; i &lt; 100; i++){ 
      System.Threading.Thread.Sleep(1);
      TcpSocket.Send(getModifiedData(MyData));
  }
  </code></pre>
  
  <p>But even with sleeping about 10% of my pockets are lost!</p>
  
  <p>I found logging to console best solution which sends 100% of pockets without loss.</p>
  
  <p>Receiver code :</p>
  
  <pre><code> // variables
      static NetworkStream^ NS;
   // CClient::NS = gcnew NetworkStream(CClient::sender);
  
  //
  Dictionary&lt;String^, Object^&gt;^ x = (Dictionary&lt;String^, Object^&gt;^)PClientFuncs::Deserialize(CClient::NS); 
  
  //method
  Object^ PClientFuncs::Deserialize(Stream^ s){
  try{
      BinaryFormatter^ formatter = gcnew BinaryFormatter();
      DeflateStream^ serializationstream = gcnew DeflateStream(s, CompressionMode::Decompress);
      return formatter-&gt;Deserialize(serializationstream);
  
  
  }
  catch (Exception^) {
      return nullptr;
  }
  }
  </code></pre>
  
  <p>So What's the problem ? Why this happening and how to fix it ?</p>