Scroll to navigation

GETSOCKOPT(2) Manual del Programador de Linux GETSOCKOPT(2)

NOMBRE

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

SINOPSIS

#include <sys/types.h>          /* Vea NOTAS */
#include <sys/socket.h>
int getsockopt(int sockfd, int level, int optname,
               void *optval, socklen_t *optlen);
int setsockopt(int sockfd, int level, int optname,
               const void *optval, 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

On success, zero is returned for the standard options. On error, -1 is returned, and errno is set appropriately.

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

El argumento sockfd no es un descriptor de archivo válido.
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.
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)).
La opción es desconocida al nivel indicado.
El descriptor de archivo sockfd no se refiere a un conector.

CONFORME A

POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD (estas llamadas de sistema se implementaron por primera vez en 4.2BSD).

NOTAS

POSIX.1 does not require the inclusion of <sys/types.h>, and this header file is not required on Linux. However, some historical (BSD) implementations required this header file, and portable applications are probably wise to include it.

For background on the socklen_t type, see accept(2).

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)

COLOFÓN

Esta página es parte de la versión 5.10 del proyecto Linux man-pages. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en https://www.kernel.org/doc/man-pages/.

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.

11 Abril 2020 Linux