Provided by: manpages-es-dev_4.27.0-1_all bug

NOMBRE

       getsockopt, setsockopt - obtiene y pone opciones en conectores (sockets)

BIBLIOTECA

       Biblioteca Estándar C (libc, -lc)

SINOPSIS

       #include <sys/socket.h>

       int getsockopt(int sockfd, int level, int optname,
                      void optval[restrict *.optlen],
                      socklen_t *restrict optlen);
       int setsockopt(int sockfd, int level, int optname,
                      const void optval[.optlen],
                      socklen_t optlen);

DESCRIPCIÓN

       getsockopt()   and  setsockopt()   manipulate  options  for the socket referred to by the file descriptor
       sockfd.  Options may exist at multiple protocol levels; they are always present at the  uppermost  socket
       level.

       When  manipulating  socket options, the level at which the option resides and the name of the option must
       be specified.  To manipulate options at the sockets API level, level  is  specified  as  SOL_SOCKET.   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,
       level should be set to the protocol number of TCP; see getprotoent(3).

       The  arguments  optval  and  optlen  are used to access option values for setsockopt().  For getsockopt()
       they identify a buffer in which  the  value  for  the  requested  option(s)  are  to  be  returned.   For
       getsockopt(),  optlen  is a value-result argument, initially containing the size of the buffer pointed to
       by optval, and modified on return to indicate the actual size of the value returned.  If no option  value
       is to be supplied or returned, optval may be NULL.

       Optname  y  cualesquiera opciones especificadas se pasan sin interpretar al módulo de protocolo apropiado
       para su interpretación. El fichero de cabecera <sys/socket.h>  contiene  definiciones  para  opciones  de
       nivel  de  conector,  descritas  más abajo. Las opciones a otros niveles de protocolo varían en formato y
       nombre; consulte las páginas apropiadas de la sección 4 del Manual.

       La mayoría de las opciones de nivel-conector utilizan un parámetro int para optval.   Para  setsockopt(),
       el  parámetro  debe  ser distinto de cero para permitir una opción booleana, o cero si la opción va a ser
       deshabilitada.

       Para una descripción de las opciones disponibles para conectores vea socket(7)  y las páginas  de  manual
       del protocolo apropiado.

VALOR DEVUELTO

       En  caso  de éxito, se devuelve cero en las operaciones estándar. En caso de error, -1, y se define errno
       al valor correspondiente.

       Netfilter allows the programmer to define custom  socket  options  with  associated  handlers;  for  such
       options, the return value on success is the value returned by the handler.

ERRORES

       EBADF  El argumento sockfd no es un descriptor de archivo válido.

       EFAULT La  dirección  apuntada  por  optval  no  está  en  un sitio válido del espacio de direcciones del
              proceso. Para getsockopt(), este error puede también ser devuelto si optlen no está  en  un  sitio
              válido del espacio de direcciones del proceso.

       EINVAL optlen  invalid  in setsockopt().  In some cases this error can also occur for an invalid value in
              optval (e.g., for the IP_ADD_MEMBERSHIP option described in ip(7)).

       ENOPROTOOPT
              La opción es desconocida al nivel indicado.

       ENOTSOCK
              El descriptor de archivo sockfd no se refiere a un conector.

ESTÁNDARES

       POSIX.1-2008.

HISTORIAL

       POSIX.1-2001, SVr4, 4.4BSD (first appeared in 4.2BSD).

ERRORES

       Algunas de las opciones de conector deberían ser manejadas a niveles más bajos del sistema.

VÉASE TAMBIÉN

       ioctl(2), socket(2), getprotoent(3), protocols(5), ip(7), packet(7), socket(7), tcp(7), udp(7), unix(7)

TRADUCCIÓN

       La traducción al español de esta página del manual fue creada  por  Juan  Piernas  <piernas@ditec.um.es>,
       Miguel Pérez Ibars <mpi79470@alu.um.es> y Marcos Fouces <marcos@debian.org>

       Esta  traducción  es  documentación  libre;  lea  la GNU General Public License Version 3 o posterior con
       respecto a las condiciones de copyright.  No existe NINGUNA RESPONSABILIDAD.

       Si encuentra algún error en la traducción de esta página  del  manual,  envíe  un  correo  electrónico  a
       debian-l10n-spanish@lists.debian.org.

Páginas de Manual de Linux 6.9.1                   2 Mayo 2024                                     getsockopt(2)