title: Use non-blocking TClientSocket inside a thread
body: <p>This <a href="http://edn.embarcadero.com/article/26693" rel="nofollow">Embarcadero</a> article describes using a blocking socket inside a thread. If I've created my socket as <code>ctNonBlocking</code> and am only writing simple messages to the socket should I be using <code>TClientWinSocket.SendText</code>:</p>
  
  <pre><code>// Inside TThread::Execute: Option 1
  strMessage := 'Hello!';
  mySocket.Socket.SendText(strMessage);
  </code></pre>
  
  <p>or should I be creating a <code>TWinSocketStream</code> and using <code>Write</code>:</p>
  
  <pre><code>// Inside TThread::Execute: Option 2
  strMessage := 'Hello!';
  stream := TWinSocketStream.Create(mySocket.Socket, 1000);
  stream.Write(strMessage[1], Length(strMessage));
  </code></pre>
  
  <p>What I am finding is that my application throws an exception when exiting (after <code>Application.Run()</code> in the DPR file and impossible to debug) which disappears if I comment out all the TClientSocket code.</p>