title: What is the difference between stream parameter and protocol parameter in socket function?
body: <pre><code>int socket(int domain, int type, int protocol);
  </code></pre>
  
  <p>As per i understood,</p>
  
  <pre><code>int domain;
  </code></pre>
  
  <p>This parameter is used for passing the address family or protocol family. I belive that there is no major difference betweent the address family and protocol family. We are using this for specifying the address type (IPV4 or IPv6).</p>
  
  <pre><code>int type;
  </code></pre>
  
  <p>This parameter is used for connection type such as UDP,TCP in network layer.</p>
  
  <pre><code>int protocol;
  </code></pre>
  
  <p>This parameter is used for the specifying the protocol  such as TCP,UDP.</p>
  
  <p>and my question is </p>
  
  <p>what is the difference between the 2nd and 3rd parameter? If we use the TCP protocol we will use the <code>SOCK_STREAM</code> , and if we use the UDP protocol we will use the <code>SOCK_DGRAM</code> in 2nd parameter. So why there is a need for two parameters in  this case? Why not we use a single parameter instead of two?</p>