title: abort() has been called on winsock recv() method
body: <p>I'm trying to receive messages from the server I'm building.</p>
  
  <p>At a certain point, when the client has connected to the server, I start a receive thread which runs constantly.
  I start is with this code:</p>
  
  <pre><code>std::thread receiveThread(&amp;NetworkingLib::Base::Receive, this);
  </code></pre>
  
  <p>It is called from a method within the same class the Receive() method is in.</p>
  
  <p>Now after that it does go into the Receive() method but it crashes when the recv() method is being called (the Winsock one).</p>
  
  <pre><code>if (ConnectSocket != INVALID_SOCKET)
  {
      iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
      ...
  }
  </code></pre>
  
  <p>All those variables contain a working value though.
  The error says:</p>
  
  <pre><code>R6010 - abort() has been called.
  </code></pre>
  
  <p>I have no idea how to solve this or what might be the problem.</p>
  
  <p>EDIT:</p>
  
  <p>Here's some extra code to show how the socket was created and such. (I left out most of the error checking)</p>
  
  <p>recvbuf and recvbuf are declared as follows:</p>
  
  <pre><code>int recvbuflen;
  char recvbuf[512];
  </code></pre>
  
  <p>After that in the constructor, recvbuflen is declared as follows:</p>
  
  <pre><code>Base::Base(void):
       recvbuflen(512)
  {
      ...
  }
  </code></pre>
  
  <p>Here's how I created the socket object:</p>
  
  <pre><code>// Create a SOCKET to connect to the server
  ConnectSocket = socket(ptr-&gt;ai_family, ptr-&gt;ai_socktype, ptr-&gt;ai_protocol);
  
  // Connect to server.
  iResult = connect( ConnectSocket, ptr-&gt;ai_addr, (int)ptr-&gt;ai_addrlen);
  </code></pre>
  
  <p>After this has been done I start the receive thread. (The first piece of code in this post)</p>