title: Login HTTP Server c++
body: <p>I am trying to create a simple http server in C++ whose home page is (in HTML): </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;home.html&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form name="input" action="login.html" method="get"&gt;
          user name: &lt;input type="text" name="user"&gt;&lt;br&gt;
          password: &lt;input type="text" name="password"&gt;
          &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When the user clicks on the submit button after filling in the user and password field, the following page should appear:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Contact info&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;User: games&lt;/h1&gt;
      &lt;h1&gt;Password: bond&lt;/h1&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am using tcpsocket and the code that handles the connection is:</p>
  
  <pre><code>tcp-&gt;listenAndAccept();
  tcp-&gt;send(url.data(), url.length());
  
  char buffer[1000];
  tcp-&gt;recv(buffer, 1000);
  cout &lt;&lt; buffer;
  tcp-&gt;recv(buffer, 1000);  
  cout &lt;&lt; buffer;
  </code></pre>
  
  <p>The main code is:</p>
  
  <pre><code>int main() {
      HTTPServer server(6060);
      server.start();
      while(true) {
          string msg;
          cin &gt;&gt; msg;
          if (msg == "x") {
              break;
          }
      }
      server.kill();
      return 0;
  }
  </code></pre>
  
  <p>And the constructor is:</p>
  
  <pre><code>HTTPServer::HTTPServer(int port) {
      url = "HTTP/1.1 302 Found \r\nContent-Type: text/html; charset=utf8 \r\nContent-Length:279\r\n\r\n&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Creating an HTML Element&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;form name=\"input\" action=\"login.html\" method=\"get\"&gt;user name: &lt;input type=\"text\" name=\"user\"&gt;&lt;br&gt;password: &lt;input type=\"text\" name=\"password\"&gt;&lt;input type=\"submit\" value=\"Submit\"&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;";
  
      tcp = new TCPSocket(port);
  }
  </code></pre>
  
  <p>Now when I enter <code>127.0.0.1:port</code> it shows me the home page and prints the response to the console but when I fill out the fields and click on the submit button nothing happens; the second <code>recv</code> doesn't receive anything. Why is the second <code>recv</code> call not receiving anything?</p>