title: C# - TcpListener - not receiving HTML Request header until refreshing the browser 2 times
body: <p>Here is my Socket which is waiting for client to connect ( browser )</p>
  <pre><code>        Server = new TcpListener(Address, Port);
          Server.Start();
  
          Console.WriteLine(&quot;--- Waiting for the client ----&quot;);
          TcpClient client = Server.AcceptTcpClient();
          this.strem = client.GetStream();
          byte[] read = new byte[900];
          this.strem.Read(read, 0, read.Length);
          Console.WriteLine(Encoding.UTF8.GetString(read));
  
          this.sendResponseOk();
  </code></pre>
  <p>The SendResponseOk Method:</p>
  <pre><code>        // html
          string htmlResponse = &quot;&lt;html&gt;&quot;;
          htmlResponse += &quot;&lt;head&gt;&lt;title&gt;ACC Data&lt;/title&gt;&lt;/head&gt;&quot;;
          htmlResponse += &quot;&lt;body&gt;&lt;h1&gt;ACC Data&lt;/h1&gt;&lt;/body&gt;&quot;;
          htmlResponse += &quot;&lt;/html&gt;&quot;;
  
          // response header
          string response = &quot;HTTP/1.1 200 OK\r\n&quot;;
          response += &quot;Content-type: text/html; charset=utf-8\r\n&quot;;
          response += &quot;Content-Length: &quot; + htmlResponse.Length + &quot;\r\n&quot;;
          response += &quot;\r\n&quot;;
          response += htmlResponse;
  
          // send
          byte[] sendData = Encoding.UTF8.GetBytes(response);
          this.strem.Write(sendData, 0, sendData.Length);
  </code></pre>
  <p>Where i'm now:</p>
  <ul>
  <li>Starting the Server [work]</li>
  <li>Open the Browser and go to Local Address:Port [Loading]</li>
  <li>Refresh ( hit Enter ) for second time, and i receive the Header [word]</li>
  <li>The HTML page loaded [Work]</li>
  </ul>
  <p>The Problem is when i access to Address:Port for the first time and keep loading until i refresh again.</p>
  <p>What i have done:</p>
  <ul>
  <li>new Thread.</li>
  <li>change TcpListener to Socket Object.</li>
  <li>Used Thread.Sleep(1000) between every steps.</li>
  </ul>
  <p>Thank you.</p>
  <p>UPDATE:</p>
  <p>On the Phone it works from the first time, no need to refresh the page
  maybe something with catch ?</p>