File: getsockopt.2

package info (click to toggle)
manpages-es 1.55-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,472 kB
  • ctags: 6
  • sloc: sh: 1,349; makefile: 63
file content (177 lines) | stat: -rw-r--r-- 6,656 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
.\" Copyright (c) 1983, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"     This product includes software developed by the University of
.\"     California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"     $Id: getsockopt.2,v 1.2 2005/02/21 16:25:16 pepin.jimenez Exp $
.\"
.\" Modified Sat Jul 24 16:19:32 1993 by Rik Faith (faith@cs.unc.edu)
.\" Modified Mon Apr 22 02:29:06 1996 by Martin Schulze (joey@infodrom.north.de)
.\" Modified Tue Aug 27 10:52:51 1996 by Andries Brouwer (aeb@cwi.nl)
.\" Modified Thu Jan 23 13:29:34 1997 by Andries Brouwer (aeb@cwi.nl)
.\" Translated Tue Dec 16 1997 by Gerardo Aburruzaga <gerardo.aburruzaga@uca.es> 
.\" Modified Sun Mar 28 21:26:46 1999 by Andries Brouwer (aeb@cwi.nl)
.\" Translation revised on Sun Apr 4 1999 by Juan Piernas <piernas@ditec.um.es>
.\" Modified 1999 by Andi Kleen <ak@muc.de>. Removed most stuff because it
.\" is in socket.7 now.
.\" Translation revised Sat Jun 26 1999 by Juan Piernas <piernas@ditec.um.es>
.\" Revisado por Miguel Pérez Ibars <mpi79470@alu.um.es> el 18-noviembre-2004
.\"
.TH GETSOCKOPT 2 "24 mayo 1999" "Página man de Linux" "Manual del Programador de Linux"
.SH NOMBRE
getsockopt, setsockopt \- obtiene y pone opciones en conectores (\fIsockets\fR)
.SH SINOPSIS
.B #include <sys/types.h>
.br
.B #include <sys/socket.h>
.sp 2
.BI "int getsockopt(int " s ", int " nivel ", int " nomopc ,
.BI "void *" valopc ", socklen_t *" lonopc );
.sp
.BI "int setsockopt(int " s ", int " nivel ", int " nomopc ,
.BI "const void *" valopc ", socklen_t " lonopc );
.SH DESCRIPCIÓN
.B Getsockopt
y
.B setsockopt
manipulan las
.I opciones
asociadas a un conector. Éstas pueden existir en múltiples niveles de
protocolo; siempre están presentes en el nivel más alto de 
.B conector.

Al manipular opciones de conector, deben especificarse el nivel en el
que reside la opción, y su nombre.

Para manipular opciones en el nivel de conector,
.I nivel
se especifica como
.BR SOL_SOCKET .
Para manipular opciones a cualquier otro nivel, se suministra el
número de protocolo del apropiado que controle la opción. Por ejemplo,
para indicar que una opción ha de ser interpretada por el protocolo
.BR TCP ,
.I nivel
debe ponerse como el número de protocolo de
.BR TCP ;
vea
.BR getprotoent (3).

Los parámetros
.I valopc
y
.I lonopc
se emplean para acceder a valores de opciones de
.BR setsockopt .
Para
.B getsockopt
identifican a un búfer en el que se pondrá el valor para la opción
pedida (u opciones). Para
.BR getsockopt ,
.I lonopc
es un parámetro por referencia, que contiene inicialmente el tamaño
del búfer  apuntado por 
.IR optval ,
y que se modifica al acabar la función para contener el tamaño real
del valor devuelto. Si no se va a suministrar o devolver un valor de
opción, 
.I valopc
puede ser NULL.

.I Nomopc
y cualesquiera opciones especificadas se pasan sin interpretar al
módulo de protocolo apropiado para su interpretación. El fichero de cabecera
.I <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
.I int
para
.IR valopc .
Para
.BR 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.
.PP
Para una descripción de las opciones disponibles para conectores vea
.BR socket (7)
y las páginas de manual del protocolo apropiado.
.SH "VALOR DEVUELTO"
Se devuelve cero en caso de éxito. En caso de error se devuelve \-1 y
.I errno
toma un valor apropiado.
.SH ERRORES
.TP
.B EBADF
El argumento
.I s
no es un descriptor válido.
.TP
.B ENOTSOCK
El argumento
.I s
es un fichero, no un conector.
.TP
.B ENOPROTOOPT
La opción es desconocida al nivel indicado.
.TP
.B EFAULT
La dirección apuntada por
.I valopc
no está en un sitio válido del espacio de direcciones del proceso. Para
.BR getsockopt ,
este error puede también ser devuelto si
.I lonopc
no está en un sitio válido del espacio de direcciones del proceso.
.SH CONFORME A
SVr4, 4.4BSD (estas primitivas aparecieron por primera vez en 4.2BSD).
SVr4 documenta los códigos de error adicionales ENOMEM y ENOSR, pero no
documenta las opciones 
.BR SO_SNDLOWAT ", " SO_RCVLOWAT ", " SO_SNDTIMEO " ni " SO_RCVTIMEO
.SH NOTA
El quinto argumento de
.BR getsockopt " y " setsockopt 
es en realidad un entero [*] (y esto es lo que tienen BSD 4.*, libc4 y libc5).
Cierta confusión en POSIX dio como resultado el actual socklen_t.
El estándar propuesto todavía no ha sido adoptado pero glibc2 ya lo sigue y
también tiene socklen_t [*]. Vea también
.BR accept (2).
.SH FALLOS
Algunas de las opciones de conector deberían ser manejadas a niveles más
bajos del sistema.
.SH "VÉASE TAMBIÉN"
.BR ioctl (2),
.BR socket (2),
.BR getprotoent (3),
.BR protocols (5),
.BR socket (7),
.BR unix (7),
.BR tcp (7)