title: how does connect() on client work with accept() on server side?
body: <p>I'm writting a simple web server, below is the the code that is just for demo purpose(not robust):</p>
  <pre><code>//server
  ...
  while (1) {
     clientlen = sizeof(struct sockaddr_storage);
     connfd = accept(listenfd, (SA *)&amp;clientaddr,&amp;clientlen); 
     getnameinfo((SA *)&amp;clientaddr, clientlen, client_hostname, MAXLINE, client_port, MAXLINE, 0);
     printf(&quot;Accepted connection from (%s, %s)\n&quot;, client_hostname, client_port);
     ...   
  }
  ...//handle the request
  </code></pre>
  <p>and below is the code on client side:</p>
  <pre><code>//client
  ...
  clientfd = socket(p-&gt;ai_family, p-&gt;ai_socktype, p-&gt;ai_protocol))
  connect(clientfd, p-&gt;ai_addr, p-&gt;ai_addrlen)
  printf(&quot;Successfully connected&quot;);
  ...
  </code></pre>
  <p>this simple web server is not a concurrent server because it should only service one client at a time. Thus, a single slow client can deny service to every other client.</p>
  <p>But when I open two terminals as clients to connect the server, and start with the first one to connect to the server and does nothing just block the server, I found in the second request, I also got &quot;Successfully connected&quot;, which is confusing me.</p>
  <p>My understanding is that since the first request is blocking after the <code>accept()</code>, then the second request should get struck in <code>accept()</code> and therefore the second reuqest's <code>connect()</code> should not be returned until the first request finishes. So why the second request's <code>connect()</code> still return even though the server can only handle one request in a time?</p>