title: C++ recv() problem
body: <p>I want to send a string "Hello there", but I only get "re". Why is that?</p>
  
  <pre><code>void Accept()
  {
      SOCKADDR_IN sock;
      int intsock = sizeof(sock);
      remoteSocket = ::accept(desc, (LPSOCKADDR)&amp;sock,  &amp;intsock);
      if(remoteSocket == -1)
      {
          cout &lt;&lt; "Error in Accept()" &lt;&lt; endl;
      }
      HandleConnection();
  }
  
  void HandleConnection()
  {
      cout &lt;&lt; "You are connected !!!" &lt;&lt; endl;
      char* temp = new char[20];
      Recv(temp);
      cout &lt;&lt; temp &lt;&lt; endl;
  }
  
  void Send(const char* buffer)
  {
      if((::send(remoteSocket, buffer, strlen(buffer), 0)) &lt; 0)
      {
          cout &lt;&lt; "Error in Send()" &lt;&lt; endl;
      }
  }
  
  void Recv(char* buffer)
  {
      int n = 0;
      while((n = ::recv(remoteSocket, buffer, strlen(buffer), 0)) 0)
      {
          buffer[n] = 0;
      }
  }
  
  ~Server()
  {
      WSACleanup();
  }
  
  };
  
  int main()
  {
      Server s;
      s.Initialize();
      s.Socket();
      s.Bind();
      s.Listen();
      while(1)
      {
          s.Accept();
      }
      return 0;
  }
  </code></pre>