Fresh IDE . sys_setsockopt.html at [947e41d975]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

File doc/lscr/data/sys_setsockopt.html artifact 2840bd3b81 part of check-in 947e41d975


 
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title><style type="text/css">
<!--
.style1 {font-size: 18px;font-weight: bold;font-family: Georgia, "Times New Roman", Times, serif;}
a{color:#0000cc;text-decoration:none}
a:visited{color:#0000cc;text-decoration:none}
.style2 {color: #660000}
-->
</style></head>
<body style="margin:0px 0px 0px 0px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#cccccc"><span class="style1" style="margin-left:5px">SYS_SETSOCKOPT</span></td>
  </tr>
  <tr>
    <td><p style="margin-left:22px;margin-top:0px"><br />
      Sets the options associated with a socket.</p>
      <p style="margin-left:10px"><strong>Arguments:</strong></p>
      <table width="100%" border="0" style="margin-left:20px; margin-right:20px">
        <tr>
          <td width="6%" valign="top"><code><em>1st </em></code></td>
          <td width="94%">Socket descriptor. </td>
        </tr>
        <tr>
          <td valign="top"><code><em>2nd</em></code></td>
          <td>Protocol level where the options described by <em>3rd</em> argument are present.<br /> 
          To manipulate options at the socket level, SOL_SOCKET is used. 
          To manipulate options at any other level the protocol number  of the appropriate protocol controlling the option is supplied. For example, to  indicate that an option is to be interpreted by the TCP protocol, <em>2nd </em>argument should be set to the protocol number of TCP.</td>
        </tr>
        <tr>
          <td valign="top"><code><em>3rd</em></code></td>
          <td>Option to retrieve. For socket level (SOL_SOCKET) options it may be one of the following values:
            <table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333">
              <tr>
                <td><table width="100%" border="0">
                  <tr>
                    <td width="14%" valign="top"><code>SO_DEBUG</code></td>
                    <td width="86%"><code>Socket debugging. Only allowed for processes with the CAP_NET_ADMIN capability or an effective user ID of 0. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_REUSEADDR</code></td>
                    <td><code>Indicates that the rules used in validating addresses supplied in a <a href="sys_bind.html">SYS_BIND</a> call should allow reuse of local  addresses. For PF_INET sockets this means that a socket may bind, except  when there is an active listening socket bound to the address. When the  listening socket is bound to INADDR_ANY with a specific port then it is  not possible to bind to this port for any local address. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_TYPE</code></td>
                    <td><code><span class="style2">*to be documented* </span></code></td>
                  </tr>

                  <tr>
                    <td valign="top"><code>SO_DONTROUTE</code></td>
                    <td><code>Don't send via a gateway, only send to directly connected hosts. The same effect  can be achieved by setting the MSG_DONTROUTE flag on a socket <a href="sys_send.html">SYS_SEND</a> operation. Expects an integer boolean  flag. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_BROADCAST</code></td>
                    <td><code>Set or get the broadcast flag. When enabled, datagram sockets receive packets  sent to a broadcast address and they are allowed to send packets to a broadcast  address. This option has no effect on stream-oriented sockets. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_SNDBUF</code></td>
                    <td><code>Sets or gets the maximum socket send buffer in bytes. The kernel doubles this  value (to allow space for bookkeeping overhead) when it is set using <a href="sys_setsockopt.html">SYS_SETSOCKOPT</a>, and this doubled value is returned by SYS_GETSOCKOPT.  The default value is set by the wmem_default sysctl and the maximum  allowed value is set by the wmem_max sysctl. The minimum (doubled) value  for this option is 2048. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_RCVBUF</code></td>
                    <td><code>Sets or gets the maximum socket receive buffer in bytes. The kernel doubles this  value (to allow space for bookkeeping overhead) when it is set using<a href="sys_setsockopt.html"> SYS_SETSOCKOPT</a>, and this doubled value is returned by SYS_GETSOCKOPT.  The default value is set by the rmem_default sysctl and the maximum  allowed value is set by the rmem_max sysctl. The minimum (doubled) value  for this option is 256. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_SNDBUFFORCE</code></td>
                    <td><code>(since Linux 2.6.14)<br />
                          Using this socket option, a privileged (CAP_NET_ADMIN) process can  perform the same task as SO_SNDBUF, but the wmem_max limit can be  overridden.</code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_RCVBUFFORCE</code></td>
                    <td><code> (since Linux 2.6.14)<br />
                          Using this socket option, a privileged (CAP_NET_ADMIN) process can  perform the same task as SO_RCVBUF, but the rmem_max limit can be  overridden.</code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_KEEPALIVE</code></td>
                    <td><code>Enable sending of keep-alive messages on connection-oriented sockets. Expects an  integer boolean flag. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_OOBINLINE</code></td>
                    <td><code>If this option is enabled, out-of-band data is directly placed into the receive  data stream. Otherwise out-of-band data is only passed when the MSG_OOB flag is set during receiving. </code></td>
                  </tr>

                  <tr>
                    <td valign="top"><code>SO_PRIORITY</code></td>
                    <td><code>Set the protocol-defined priority for all packets to be sent on this socket.  Linux uses this value to order the networking queues: packets with a higher  priority may be processed first depending on the selected device queueing  discipline. For IP level , this also sets the  IP type-of-service (TOS) field for outgoing packets. Setting a priority outside  the range 0 to 6 requires the CAP_NET_ADMIN capability. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_LINGER</code></td>
                    <td><code>Set or gets the SO_LINGER option. The argument is a <em>linger </em>structure. <br />
                          <br />
                      </code>
                        <table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333">
                          <tr>
                            <td><code>struc linger<br>
                              {<br />
                              .l_onoff         &nbsp;rd 1  ; linger active<br />
                              .l_linger        rd 1 ;  how many seconds to linger for<br />
                            }</code></td>
                          </tr>
                        </table>
                      <code><br />
                        When enabled, a <a href="6.html">sys_close</a> or <a href="sys_shutdown.html">SYS_SHUTDOWN</a> will not return until all  queued messages for the socket have been successfully sent or the linger timeout  has been reached. Otherwise, the call returns immediately and the closing is  done in the background. When the socket is closed as part of <a href="1.html">sys_exit</a>, it always lingers in the background. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_BSDCOMPAT</code></td>
                    <td><code>This option is obsolete Linux will generate a  kernel warning (printk()) if a program uses this option.</code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_PASSCRED</code></td>
                    <td><code>Enable or disable the receiving of the SCM_CREDENTIALS control message.  For more information see <em>man 7 unix</em>. </code></td>
                  </tr>

                  <tr>
                    <td valign="top"><code>SO_RCVLOWAT</code></td>
                    <td><code>Specify the minimum number of bytes in the buffer until the socket layer will  pass the data to the user on receiving. This value is initialised to 1. SO_RCVLOWAT is changeable only since Linux 2.4. The <a href="82.html">sys_select</a> and <a href="168.html">sys_poll</a> system calls currently do not respect  the SO_RCVLOWAT setting on Linux, and mark a socket readable when even a  single byte of data is available. A subsequent read from the socket will block  until SO_RCVLOWAT bytes are available. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_SNDLOWAT</code></td>
                    <td><code>This option is not implemented and <a href="sys_setsockopt.html">SYS_SETSOCKOPT</a> will always fail with -ENOPROTOOPT.</code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_RCVTIMEO</code></td>
                    <td><code>Specify the receiving timeouts until reporting an error. The  parameter is a <em>timeval </em>struct. If an input function blocks for  this period of time, and data has been received, the return value of  that function will be the amount of data transferred; if no data has been  transferred and the timeout has been reached then -1 is returned with <em>-</em>EAGAIN or -EWOULDBLOCK just as if the socket was specified to  be nonblocking. If the timeout is set to zero (the default) then the operation  will never timeout. </code></td>
                  </tr>
                  <tr>
                    <td valign="top"><code>SO_SNDTIMEO</code></td>
                    <td><code>Specify the  sending timeouts until reporting an error. The  parameter is a <em>timeval </em>struct. If an  output function blocks for  this period of time, and data has been sent, the return value of  that function will be the amount of data transferred; if no data has been  transferred and the timeout has been reached then -1 is returned with <em>-</em>EAGAIN or -EWOULDBLOCK just as if the socket was specified to  be nonblocking. If the timeout is set to zero (the default) then the operation  will never timeout. </code></td>
                  </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td valign="top"><code><em>4th</em></code></td>
          <td>Pointer to a buffer containing parameters for the option specified in <em>3rd</em> argument. </td>
        </tr>
        <tr>
          <td valign="top"><code><em>5th</em></code></td>
          <td>Size of the buffer pointed by <em>4th </em>argument.</td>
        </tr>
      </table>
      <p style="margin-left:10px" ><strong>Return values</strong></p>
      <p style="margin-left:22px;margin-right:10px" >If the system call succeeds the return value is 0.<br />
If the system call fails the return value is one of the following <em>errno</em> values:</p>
      <table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333;margin-left:22px;margin-right:22px">
        <tr>
          <td><table width="100%" border="0">
              <tr>
                <td width="10%" valign="top"><code>-EBADF </code></td>
                <td width="90%"><code>The <em>1st</em> argument is not a valid descriptor. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-EFAULT </code></td>
                <td><code>The address pointed to by <em>4th</em> argument  is not in a valid part of the process  address space.</code></td>
              </tr>
              <tr>
                <td valign="top"><code>-ENOPROTOOPT </code></td>
                <td><code>The option is unknown at the level indicated. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-ENOTSOCK </code></td>
                <td><code>The <em>1st</em> argument is a file, not a socket. </code></td>
              </tr>
          </table></td>
        </tr>
      </table>
      <p style="margin-left:10px"><strong>Remarks</strong></p>
      <p style="margin-left:22px">n/a</p>
      <p style="margin-left:10px"><strong>Compatibility</strong></p>
    <p style="margin-left:22px">n/a</p></td>
  </tr>
</table></body></html>