title: closing client socket and keeping server socket active
body: <p>I am establishing a server-client connection using TCP sockets. Whenever I close the client socket my server is also closed. But I want only my client to be closed and my server must wait for next <code>accept()</code>.   </p>
  
  <p>Server side:   </p>
  
  <pre><code>{
  bind(lfd,(struct sockaddr*)&amp;serv_addr, sizeof(serv_addr));
  listen(lfd, 10);
     while(1)
     {
          cfd = accept(lfd, (struct sockaddr*)NULL, NULL);
     //server must wait here after client closes the connection application code
          close(lfd);
      }
  }
  </code></pre>
  
  <p>client side:</p>
  
  <pre><code>inet_pton(AF_INET, argv[1], &amp;serv_addr.sin_addr);
  connect(fd, (struct sockaddr *)&amp;serv_addr, sizeof(serv_addr));
  // ... application code
  if(c == 1)
     close(fd);
  </code></pre>