GETSOCKOPT(3)              POSIX Programmer's Manual             GETSOCKOPT(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       getsockopt -- get the socket options

SSYYNNOOPPSSIISS
       #include <sys/socket.h>

       int getsockopt(int _s_o_c_k_e_t, int _l_e_v_e_l, int _o_p_t_i_o_n___n_a_m_e_,
           void *restrict _o_p_t_i_o_n___v_a_l_u_e, socklen_t *restrict _o_p_t_i_o_n___l_e_n);

DDEESSCCRRIIPPTTIIOONN
       The _g_e_t_s_o_c_k_o_p_t() function manipulates options associated with a socket.

       The _g_e_t_s_o_c_k_o_p_t() function shall retrieve the value for the option
       specified by the _o_p_t_i_o_n___n_a_m_e argument for the socket specified by the
       _s_o_c_k_e_t argument. If the size of the option value is greater than
       _o_p_t_i_o_n___l_e_n, the value stored in the object pointed to by the
       _o_p_t_i_o_n___v_a_l_u_e argument shall be silently truncated. Otherwise, the
       object pointed to by the _o_p_t_i_o_n___l_e_n argument shall be modified to
       indicate the actual length of the value.

       The _l_e_v_e_l argument specifies the protocol level at which the option
       resides. To retrieve options at the socket level, specify the _l_e_v_e_l
       argument as SOL_SOCKET. To retrieve options at other levels, supply the
       appropriate level identifier for the protocol controlling the option.
       For example, to indicate that an option is interpreted by the TCP
       (Transmission Control Protocol), set _l_e_v_e_l to IPPROTO_TCP as defined in
       the _<_n_e_t_i_n_e_t_/_i_n_._h_> header.

       The socket in use may require the process to have appropriate
       privileges to use the _g_e_t_s_o_c_k_o_p_t() function.

       The _o_p_t_i_o_n___n_a_m_e argument specifies a single option to be retrieved. It
       can be one of the socket-level options defined in <<ssyyss__ssoocckkeett..hh>> and
       described in _S_e_c_t_i_o_n _2_._1_0_._1_6, _U_s_e _o_f _O_p_t_i_o_n_s.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _g_e_t_s_o_c_k_o_p_t() shall return 0; otherwise, -1
       shall be returned and _e_r_r_n_o set to indicate the error.

EERRRROORRSS
       The _g_e_t_s_o_c_k_o_p_t() function shall fail if:

       EEBBAADDFF  The _s_o_c_k_e_t argument is not a valid file descriptor.

       EEIINNVVAALL The specified option is invalid at the specified socket level.

       EENNOOPPRROOTTOOOOPPTT
              The option is not supported by the protocol.

       EENNOOTTSSOOCCKK
              The _s_o_c_k_e_t argument does not refer to a socket.

       The _g_e_t_s_o_c_k_o_p_t() function may fail if:

       EEAACCCCEESS The calling process does not have appropriate privileges.

       EEIINNVVAALL The socket has been shut down.

       EENNOOBBUUFFSS
              Insufficient resources are available in the system to complete
              the function.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _S_e_c_t_i_o_n _2_._1_0_._1_6, _U_s_e _o_f _O_p_t_i_o_n_s, _b_i_n_d(), _c_l_o_s_e(), _e_n_d_p_r_o_t_o_e_n_t(),
       _s_e_t_s_o_c_k_o_p_t(), _s_o_c_k_e_t()

       The Base Definitions volume of POSIX.1-2008, <<ssyyss__ssoocckkeett..hh>>,
       <<nneettiinneett__iinn..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                        GETSOCKOPT(3)
