title: Active close vs passive close in terms of socket API?
body: <p>In TCP we say one side of the connection performs an "active close" and the other side performs a "passive close".</p>
  
  <p>In terms of the Linux sockets API, how do you differentiate the active close and the passive close?</p>
  
  <p>For example, suppose we have two connected Linux TCP sockets, A and P, that have exchanged information over the application-level protocol and they are both aware that it is time to close their sockets (neither expect to send or receive any more data to or from each other).</p>
  
  <p>We want socket A to perform the active close, and for P to be the passive close.</p>
  
  <p>There are a few things A and P could do.  For example:</p>
  
  <ul>
  <li>call shutdown(SHUT_WR)</li>
  <li>call recv and expect to get 0 back</li>
  <li>call close.</li>
  <li>something else</li>
  </ul>
  
  <p>What combination of these things and in what order should A do?... and what combination of these things and in what order should P do?</p>