title: Debug Assertion
body: <p>I have receiving an error like &quot;<em>Debug Assertion Failed</em>&quot; message when the debug comes to the line  &quot;<em>valread = read(new_socket, buffer, 256)</em>&quot; When I press ignore button, I see exception</p>
  <p>&quot;<em>Unhandled exception at 0x00007FFCAC2EAFAC (ucrtbased.dll) in soketSample.exe: An invalid parameter was passed to a function that considers invalid parameters fatal</em>&quot;</p>
  <p>My Code is below;</p>
  <pre><code>#include &lt;io.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ws2tcpip.h&gt;
  #include &lt;MSWSock.h&gt;
  #include &lt;share.h&gt;
  #include &lt;atltypes.h&gt;
  
  
  using namespace std;
  
  int main(int argc, char const *argv[])
  {
  
      int server_fd, new_socket, valread;
      struct sockaddr_in address;
      int opt = 1;
      int addrlen = sizeof(address);
      char buffer[256] = {};
      char *hello = &quot;Hello from server&quot;;
  
      WSADATA Data;
      WSAStartup(MAKEWORD(2, 2), &amp;Data);
  
      //Creating socket file descriptor
      if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0)
      {
          perror(&quot;ERROR opening socket&quot;);
          exit(EXIT_FAILURE);
      }
  
      
      if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&amp; opt, sizeof(opt)) &lt; 0)
      {
          perror(&quot;Failed to set the SO_REUSEADDR option&quot;);
          exit(EXIT_FAILURE);
      }
  
      
      address.sin_family = AF_INET;
      address.sin_addr.s_addr = INADDR_ANY; //inet_addr(&quot;127.0.0.1&quot;);
      address.sin_port = htons(30035);
  
      // Forcefully attaching socket to the port 8080 
      if (bind(server_fd, (struct sockaddr*)&amp;address, sizeof(address)) &lt; 0)
      {
          perror(&quot;bind failed&quot;);
          exit(EXIT_FAILURE);
      }
      if (listen(server_fd, 5) &lt; 0)
      {
          perror(&quot;listen&quot;);
          exit(EXIT_FAILURE);
      }
      if ((new_socket = accept(server_fd, (struct sockaddr*)&amp;address, (socklen_t*)&amp;addrlen)) &lt; 0)
      {
          perror(&quot;accept&quot;);
          exit(EXIT_FAILURE);
      }
  
      
      Sleep(3000);
      valread = read(new_socket, buffer, 256); ****
  
      send(new_socket, &quot;Hello, world!\n&quot;, 13, 0);
      printf(&quot;%s\n&quot;, buffer);
      
      return 0; 
  
  }
  </code></pre>
  <p>what is wrong in my code,  could you help me?</p>