title: Errors after upgrading from winsock.h to winsock2.h
body: <p>I have a program in C that redirects tcp ports. i was using <code>winsock.h</code> previously and the application worked fine. </p>
  
  <p>I have now included winsock2.h instead of <code>winsock.h</code> to get advanced functions like <code>WSAioctl()</code> which were not available in <code>winsock.h</code>.</p>
  
  <p>I have included the <code>winsock2.h</code> in the right order, that is, before <code>windows.h</code> so that the <code>windows.h</code> does not include the <code>winsock.h</code>. I have also tried other methods of avoiding <code>winsock.h</code> and <code>winsock2.h</code> conflicts that is defining <code>WIN32_LEAN_AND_MEAN</code> before <code>windows.h</code>. </p>
  
  <p>I have also linked the <code>ws2_32.lib</code> instead of <code>wsock32.lib</code>.</p>
  
  <p><strong>Problem:</strong> The application successfully builds with <code>winsock2.h</code> without errors but when i run the program in debug mode (or otherwise), it crashes and triggers several breakpoints one of which is at <code>_CrtIsValidHeapPointer()</code>.
  What could be the possible reason for these exceptions?</p>
  
  <p>Platform: VS2012 on Windows 7 Professional 64 bit.</p>