OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [ref/] [net-common-tcpip-manpages-getsockopt.html] - Blame information for rev 28

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 unneback
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
2
<!-- This material may be distributed only subject to the terms      -->
3
<!-- and conditions set forth in the Open Publication License, v1.0  -->
4
<!-- or later (the latest version is presently available at          -->
5
<!-- http://www.opencontent.org/openpub/).                           -->
6
<!-- Distribution of the work or derivative of the work in any       -->
7
<!-- standard (paper) book form is prohibited unless prior           -->
8
<!-- permission is obtained from the copyright holder.               -->
9
<HTML
10
><HEAD
11
><TITLE
12
>getsockopt</TITLE
13
><meta name="MSSmartTagsPreventParsing" content="TRUE">
14
<META
15
NAME="GENERATOR"
16
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17
"><LINK
18
REL="HOME"
19
TITLE="eCos Reference Manual"
20
HREF="ecos-ref.html"><LINK
21
REL="UP"
22
TITLE="TCP/IP Library Reference"
23
HREF="tcpip-library-reference.html"><LINK
24
REL="PREVIOUS"
25
TITLE="getsockname"
26
HREF="net-common-tcpip-manpages-getsockname.html"><LINK
27
REL="NEXT"
28
TITLE="ioctl"
29
HREF="net-common-tcpip-manpages-ioctl.html"></HEAD
30
><BODY
31
CLASS="SECT1"
32
BGCOLOR="#FFFFFF"
33
TEXT="#000000"
34
LINK="#0000FF"
35
VLINK="#840084"
36
ALINK="#0000FF"
37
><DIV
38
CLASS="NAVHEADER"
39
><TABLE
40
SUMMARY="Header navigation table"
41
WIDTH="100%"
42
BORDER="0"
43
CELLPADDING="0"
44
CELLSPACING="0"
45
><TR
46
><TH
47
COLSPAN="3"
48
ALIGN="center"
49
>eCos Reference Manual</TH
50
></TR
51
><TR
52
><TD
53
WIDTH="10%"
54
ALIGN="left"
55
VALIGN="bottom"
56
><A
57
HREF="net-common-tcpip-manpages-getsockname.html"
58
ACCESSKEY="P"
59
>Prev</A
60
></TD
61
><TD
62
WIDTH="80%"
63
ALIGN="center"
64
VALIGN="bottom"
65
>Chapter 38. TCP/IP Library Reference</TD
66
><TD
67
WIDTH="10%"
68
ALIGN="right"
69
VALIGN="bottom"
70
><A
71
HREF="net-common-tcpip-manpages-ioctl.html"
72
ACCESSKEY="N"
73
>Next</A
74
></TD
75
></TR
76
></TABLE
77
><HR
78
ALIGN="LEFT"
79
WIDTH="100%"></DIV
80
><DIV
81
CLASS="SECT1"
82
><H1
83
CLASS="SECT1"
84
><A
85
NAME="NET-COMMON-TCPIP-MANPAGES-GETSOCKOPT">getsockopt</H1
86
><TABLE
87
BORDER="5"
88
BGCOLOR="#E0E0F0"
89
WIDTH="70%"
90
><TR
91
><TD
92
><PRE
93
CLASS="SCREEN"
94
>GETSOCKOPT(2)                 System Calls Manual                GETSOCKOPT(2)
95
 
96
NAME
97
     getsockopt, setsockopt - get and set options on sockets
98
 
99
SYNOPSIS
100
     #include &lt;sys/types.h&#62;
101
     #include &lt;sys/socket.h&#62;
102
 
103
     int
104
     getsockopt(int s, int level, int optname, void *optval,
105
             socklen_t *optlen);
106
 
107
     int
108
     setsockopt(int s, int level, int optname, const void *optval,
109
             socklen_t optlen);
110
 
111
DESCRIPTION
112
     getsockopt() and setsockopt() manipulate the options associated with a
113
     socket.  Options may exist at multiple protocol levels; they are always
114
     present at the uppermost ``socket'' level.
115
 
116
     When manipulating socket options the level at which the option resides
117
     and the name of the option must be specified.  To manipulate options at
118
     the socket level, level is specified as SOL_SOCKET.  To manipulate
119
     options at any other level the protocol number of the appropriate proto-
120
     col controlling the option is supplied.  For example, to indicate that an
121
     option is to be interpreted by the TCP protocol, level should be set to
122
     the protocol number of TCP; see getprotoent(3).
123
 
124
     The parameters optval and optlen are used to access option values for
125
     setsockopt().  For getsockopt() they identify a buffer in which the value
126
     for the requested option(s) are to be returned.  For getsockopt(), optlen
127
     is a value-result parameter, initially containing the size of the buffer
128
     pointed to by optval, and modified on return to indicate the actual size
129
     of the value returned.  If no option value is to be supplied or returned,
130
     optval may be NULL.
131
 
132
     optname and any specified options are passed uninterpreted to the appro-
133
     priate protocol module for interpretation.  The include file
134
     &lt;sys/socket.h&#62; contains definitions for socket level options, described
135
     below.  Options at other protocol levels vary in format and name; consult
136
     the appropriate entries in section 4 of the manual.
137
 
138
     Most socket-level options utilize an int parameter for optval.  For
139
     setsockopt(), the parameter should be non-zero to enable a boolean
140
     option, or zero if the option is to be disabled.  SO_LINGER uses a struct
141
     linger parameter, defined in &lt;sys/socket.h&#62;, which specifies the desired
142
     state of the option and the linger interval (see below).  SO_SNDTIMEO and
143
     SO_RCVTIMEO use a struct timeval parameter, defined in &lt;sys/time.h&#62;.
144
 
145
     The following options are recognized at the socket level.  Except as
146
     noted, each may be examined with getsockopt() and set with setsockopt().
147
 
148
           SO_DEBUG        enables recording of debugging information
149
           SO_REUSEADDR    enables local address reuse
150
           SO_REUSEPORT    enables duplicate address and port bindings
151
           SO_KEEPALIVE    enables keep connections alive
152
           SO_DONTROUTE    enables routing bypass for outgoing messages
153
           SO_LINGER       linger on close if data present
154
           SO_BROADCAST    enables permission to transmit broadcast messages
155
           SO_OOBINLINE    enables reception of out-of-band data in band
156
           SO_SNDBUF       set buffer size for output
157
           SO_RCVBUF       set buffer size for input
158
           SO_SNDLOWAT     set minimum count for output
159
           SO_RCVLOWAT     set minimum count for input
160
           SO_SNDTIMEO     set timeout value for output
161
           SO_RCVTIMEO     set timeout value for input
162
           SO_TYPE         get the type of the socket (get only)
163
           SO_ERROR        get and clear error on the socket (get only)
164
 
165
     SO_DEBUG enables debugging in the underlying protocol modules.
166
     SO_REUSEADDR indicates that the rules used in validating addresses sup-
167
     plied in a bind(2) call should allow reuse of local addresses.
168
     SO_REUSEPORT allows completely duplicate bindings by multiple processes
169
     if they all set SO_REUSEPORT before binding the port.  This option per-
170
     mits multiple instances of a program to each receive UDP/IP multicast or
171
     broadcast datagrams destined for the bound port.  SO_KEEPALIVE enables
172
     the periodic transmission of messages on a connected socket.  Should the
173
     connected party fail to respond to these messages, the connection is con-
174
     sidered broken and processes using the socket are notified via a SIGPIPE
175
     signal when attempting to send data.  SO_DONTROUTE indicates that outgo-
176
     ing messages should bypass the standard routing facilities.  Instead,
177
     messages are directed to the appropriate network interface according to
178
     the network portion of the destination address.
179
 
180
     SO_LINGER controls the action taken when unsent messages are queued on
181
     socket and a close(2) is performed.  If the socket promises reliable
182
     delivery of data and SO_LINGER is set, the system will block the process
183
     on the close(2) attempt until it is able to transmit the data or until it
184
     decides it is unable to deliver the information (a timeout period mea-
185
     sured in seconds, termed the linger interval, is specified in the
186
     setsockopt() call when SO_LINGER is requested).  If SO_LINGER is disabled
187
     and a close(2) is issued, the system will process the close in a manner
188
     that allows the process to continue as quickly as possible.
189
 
190
     The option SO_BROADCAST requests permission to send broadcast datagrams
191
     on the socket.  Broadcast was a privileged operation in earlier versions
192
     of the system.  With protocols that support out-of-band data, the
193
     SO_OOBINLINE option requests that out-of-band data be placed in the nor-
194
     mal data input queue as received; it will then be accessible with recv(2)
195
     or read(2) calls without the MSG_OOB flag.  Some protocols always behave
196
     as if this option is set.  SO_SNDBUF and SO_RCVBUF are options to adjust
197
     the normal buffer sizes allocated for output and input buffers, respec-
198
     tively.  The buffer size may be increased for high-volume connections, or
199
     may be decreased to limit the possible backlog of incoming data.  The
200
     system places an absolute limit on these values.
201
 
202
     SO_SNDLOWAT is an option to set the minimum count for output operations.
203
     Most output operations process all of the data supplied by the call,
204
     delivering data to the protocol for transmission and blocking as neces-
205
     sary for flow control.  Nonblocking output operations will process as
206
     much data as permitted subject to flow control without blocking, but will
207
     process no data if flow control does not allow the smaller of the low
208
     water mark value or the entire request to be processed.  A select(2) or
209
     poll(2) operation testing the ability to write to a socket will return
210
     true only if the low water mark amount could be processed.  The default
211
     value for SO_SNDLOWAT is set to a convenient size for network efficiency,
212
     often 1024.  SO_RCVLOWAT is an option to set the minimum count for input
213
     operations.  In general, receive calls will block until any (non-zero)
214
     amount of data is received, then return with the smaller of the amount
215
     available or the amount requested.  The default value for SO_RCVLOWAT is
216
     1.  If SO_RCVLOWAT is set to a larger value, blocking receive calls nor-
217
     mally wait until they have received the smaller of the low water mark
218
     value or the requested amount.  Receive calls may still return less than
219
     the low water mark if an error occurs, a signal is caught, or the type of
220
     data next in the receive queue is different than that returned.
221
 
222
     SO_SNDTIMEO is an option to set a timeout value for output operations.
223
     It accepts a struct timeval parameter with the number of seconds and
224
     microseconds used to limit waits for output operations to complete.  If a
225
     send operation has blocked for this much time, it returns with a partial
226
     count or with the error EWOULDBLOCK if no data was sent.  In the current
227
     implementation, this timer is restarted each time additional data are
228
     delivered to the protocol, implying that the limit applies to output por-
229
     tions ranging in size from the low water mark to the high water mark for
230
     output.  SO_RCVTIMEO is an option to set a timeout value for input opera-
231
     tions.  It accepts a struct timeval parameter with the number of seconds
232
     and microseconds used to limit waits for input operations to complete.
233
     In the current implementation, this timer is restarted each time addi-
234
     tional data are received by the protocol, and thus the limit is in effect
235
     an inactivity timer.  If a receive operation has been blocked for this
236
     much time without receiving additional data, it returns with a short
237
     count or with the error EWOULDBLOCK if no data were received.
238
 
239
     Finally, SO_TYPE and SO_ERROR are options used only with getsockopt().
240
     SO_TYPE returns the type of the socket, such as SOCK_STREAM; it is useful
241
     for servers that inherit sockets on startup.  SO_ERROR returns any pend-
242
     ing error on the socket and clears the error status.  It may be used to
243
     check for asynchronous errors on connected datagram sockets or for other
244
     asynchronous errors.
245
 
246
RETURN VALUES
247
     A 0 is returned if the call succeeds, -1 if it fails.
248
 
249
ERRORS
250
     The call succeeds unless:
251
 
252
     [EBADF]            The argument s is not a valid descriptor.
253
 
254
     [ENOTSOCK]         The argument s is a file, not a socket.
255
 
256
     [ENOPROTOOPT]      The option is unknown at the level indicated.
257
 
258
     [EFAULT]           The address pointed to by optval is not in a valid
259
                        part of the process address space.  For getsockopt(),
260
                        this error may also be returned if optlen is not in a
261
                        valid part of the process address space.
262
 
263
SEE ALSO
264
     connect(2), ioctl(2), poll(2), select(2), poll(2), socket(2),
265
     getprotoent(3), protocols(5)
266
 
267
BUGS
268
     Several of the socket options should be handled at lower levels of the
269
     system.
270
 
271
HISTORY
272
     The getsockopt() system call appeared in 4.2BSD.
273
 
274
BSD                            February 15, 1999                           BSD
275
    </PRE
276
></TD
277
></TR
278
></TABLE
279
></DIV
280
><DIV
281
CLASS="NAVFOOTER"
282
><HR
283
ALIGN="LEFT"
284
WIDTH="100%"><TABLE
285
SUMMARY="Footer navigation table"
286
WIDTH="100%"
287
BORDER="0"
288
CELLPADDING="0"
289
CELLSPACING="0"
290
><TR
291
><TD
292
WIDTH="33%"
293
ALIGN="left"
294
VALIGN="top"
295
><A
296
HREF="net-common-tcpip-manpages-getsockname.html"
297
ACCESSKEY="P"
298
>Prev</A
299
></TD
300
><TD
301
WIDTH="34%"
302
ALIGN="center"
303
VALIGN="top"
304
><A
305
HREF="ecos-ref.html"
306
ACCESSKEY="H"
307
>Home</A
308
></TD
309
><TD
310
WIDTH="33%"
311
ALIGN="right"
312
VALIGN="top"
313
><A
314
HREF="net-common-tcpip-manpages-ioctl.html"
315
ACCESSKEY="N"
316
>Next</A
317
></TD
318
></TR
319
><TR
320
><TD
321
WIDTH="33%"
322
ALIGN="left"
323
VALIGN="top"
324
>getsockname</TD
325
><TD
326
WIDTH="34%"
327
ALIGN="center"
328
VALIGN="top"
329
><A
330
HREF="tcpip-library-reference.html"
331
ACCESSKEY="U"
332
>Up</A
333
></TD
334
><TD
335
WIDTH="33%"
336
ALIGN="right"
337
VALIGN="top"
338
>ioctl</TD
339
></TR
340
></TABLE
341
></DIV
342
></BODY
343
></HTML
344
>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.