Annotation of 43BSDTahoe/man/man2/getsockopt.2, revision 1.1

1.1     ! root        1: .\" Copyright (c) 1983 Regents of the University of California.
        !             2: .\" All rights reserved.  The Berkeley software License Agreement
        !             3: .\" specifies the terms and conditions for redistribution.
        !             4: .\"
        !             5: .\"    @(#)getsockopt.2        6.4 (Berkeley) 5/23/86
        !             6: .\"
        !             7: .TH GETSOCKOPT 2 "May 23, 1986"
        !             8: .UC 5
        !             9: .SH NAME
        !            10: getsockopt, setsockopt \- get and set options on sockets
        !            11: .SH SYNOPSIS
        !            12: .nf
        !            13: .ft B
        !            14: #include <sys/types.h>
        !            15: #include <sys/socket.h>
        !            16: .PP
        !            17: .ft B
        !            18: getsockopt(s, level, optname, optval, optlen)
        !            19: int s, level, optname;
        !            20: char *optval;
        !            21: int *optlen;
        !            22: .sp
        !            23: setsockopt(s, level, optname, optval, optlen)
        !            24: int s, level, optname;
        !            25: char *optval;
        !            26: int optlen;
        !            27: .fi
        !            28: .SH DESCRIPTION
        !            29: .I Getsockopt
        !            30: and
        !            31: .I setsockopt
        !            32: manipulate
        !            33: .I options
        !            34: associated with a socket.  Options may exist at multiple
        !            35: protocol levels; they are always present at the uppermost
        !            36: ``socket'' level.
        !            37: .PP
        !            38: When manipulating socket options the level at which the
        !            39: option resides and the name of the option must be specified.
        !            40: To manipulate options at the ``socket'' level,
        !            41: .I level
        !            42: is specified as SOL_SOCKET.  To manipulate options at any
        !            43: other level the protocol number of the appropriate protocol
        !            44: controlling the option is supplied.  For example,
        !            45: to indicate that an option is to be interpreted by the TCP protocol,
        !            46: .I level
        !            47: should be set to the protocol number of TCP; see
        !            48: .IR getprotoent (3N).
        !            49: .PP
        !            50: The parameters
        !            51: .I optval
        !            52: and
        !            53: .I optlen
        !            54: are used to access option values for
        !            55: .IR setsockopt .
        !            56: For
        !            57: .I getsockopt
        !            58: they identify a buffer in which the value for the
        !            59: requested option(s) are to be returned.  For
        !            60: .IR getsockopt ,
        !            61: .I optlen
        !            62: is a value-result parameter, initially containing the
        !            63: size of the buffer pointed to by
        !            64: .IR optval ,
        !            65: and modified on return to indicate the actual size of
        !            66: the value returned.  If no option value is
        !            67: to be supplied or returned,
        !            68: .I optval
        !            69: may be supplied as 0.
        !            70: .PP
        !            71: .I Optname
        !            72: and any specified options are passed uninterpreted to the appropriate
        !            73: protocol module for interpretation.
        !            74: The include file
        !            75: .RI < sys/socket.h >
        !            76: contains definitions for ``socket'' level options, described below.
        !            77: Options at other protocol levels vary in format and
        !            78: name; consult the appropriate entries in section (4P).
        !            79: .PP
        !            80: Most socket-level options take an
        !            81: .I int
        !            82: parameter for
        !            83: .IR optval .
        !            84: For
        !            85: .IR setsockopt ,
        !            86: the parameter should non-zero to enable a boolean option,
        !            87: or zero if the option is to be disabled.
        !            88: SO_LINGER uses a
        !            89: .I struct linger
        !            90: parameter, defined in
        !            91: .RI < sys/socket.h >,
        !            92: which specifies the desired state of the option and the
        !            93: linger interval (see below).
        !            94: .PP
        !            95: The following options are recognized at the socket level.
        !            96: Except as noted, each may be examined with
        !            97: .I getsockopt
        !            98: and set with
        !            99: .IR setsockopt .
        !           100: .PP
        !           101: .RS
        !           102: .ta \w'SO_BROADCAST\ \ \ \ 'u
        !           103: .nf
        !           104: SO_DEBUG       toggle recording of debugging information
        !           105: SO_REUSEADDR   toggle local address reuse
        !           106: SO_KEEPALIVE   toggle keep connections alive
        !           107: SO_DONTROUTE   toggle routing bypass for outgoing messages
        !           108: SO_LINGER      linger on close if data present
        !           109: SO_BROADCAST   toggle permission to transmit broadcast messages
        !           110: SO_OOBINLINE   toggle reception of out-of-band data in band
        !           111: SO_SNDBUF      set buffer size for output
        !           112: SO_RCVBUF      set buffer size for input
        !           113: SO_TYPE        get the type of the socket (get only)
        !           114: SO_ERROR       get and clear error on the socket (get only)
        !           115: .fi
        !           116: .RE
        !           117: .PP
        !           118: SO_DEBUG enables debugging in the underlying protocol modules.
        !           119: SO_REUSEADDR indicates that the rules used in validating addresses supplied
        !           120: in a
        !           121: .IR bind (2)
        !           122: call should allow reuse of local addresses.  SO_KEEPALIVE enables the
        !           123: periodic transmission of messages on a connected socket.  Should the
        !           124: connected party fail to respond to these messages, the connection is
        !           125: considered broken and processes using the socket are notified via a
        !           126: SIGPIPE signal.  SO_DONTROUTE indicates that outgoing messages should
        !           127: bypass the standard routing facilities.  Instead, messages are directed
        !           128: to the appropriate network interface according to the network portion
        !           129: of the destination address.
        !           130: .PP
        !           131: SO_LINGER controls the action taken when unsent messags
        !           132: are queued on socket and a 
        !           133: .IR close (2)
        !           134: is performed.
        !           135: If the socket promises reliable delivery of data and SO_LINGER is set,
        !           136: the system will block the process on the 
        !           137: .I close
        !           138: attempt until it is able to transmit the data or until it decides it
        !           139: is unable to deliver the information (a timeout period, termed the
        !           140: linger interval, is specified in the
        !           141: .IR setsockopt 
        !           142: call when SO_LINGER is requested). 
        !           143: If SO_LINGER is disabled and a 
        !           144: .I close
        !           145: is issued, the system will process the close in a manner that allows
        !           146: the process to continue as quickly as possible.
        !           147: .PP
        !           148: The option SO_BROADCAST requests permission to send broadcast datagrams
        !           149: on the socket.
        !           150: Broadcast was a privileged operation in earlier versions of the system.
        !           151: With protocols that support out-of-band data, the SO_OOBINLINE option
        !           152: requests that out-of-band data be placed in the normal data input queue
        !           153: as received; it will then be accessible with
        !           154: .I recv
        !           155: or
        !           156: .I read
        !           157: calls without the MSG_OOB flag.
        !           158: SO_SNDBUF and SO_RCVBUF are options to adjust the normal
        !           159: buffer sizes allocated for output and input buffers, respectively.
        !           160: The buffer size may be increased for high-volume connections,
        !           161: or may be decreased to limit the possible backlog of incoming data.
        !           162: The system places an absolute limit on these values.
        !           163: Finally, SO_TYPE and SO_ERROR are options used only with
        !           164: .IR setsockopt .
        !           165: SO_TYPE returns the type of the socket, such as SOCK_STREAM;
        !           166: it is useful for servers that inherit sockets on startup.
        !           167: SO_ERROR returns any pending error on the socket and clears
        !           168: the error status.
        !           169: It may be used to check for asynchronous errors on connected
        !           170: datagram sockets or for other asynchronous errors.
        !           171: .SH "RETURN VALUE"
        !           172: A 0 is returned if the call succeeds, \-1 if it fails.
        !           173: .SH ERRORS
        !           174: The call succeeds unless:
        !           175: .TP 20
        !           176: [EBADF]
        !           177: The argument \fIs\fP is not a valid descriptor.
        !           178: .TP 20
        !           179: [ENOTSOCK]
        !           180: The argument \fIs\fP is a file, not a socket.
        !           181: .TP 20
        !           182: [ENOPROTOOPT]
        !           183: The option is unknown at the level indicated.
        !           184: .TP 20
        !           185: [EFAULT]
        !           186: The address pointed to by 
        !           187: .I optval
        !           188: is not in a valid part of the process address space.
        !           189: For
        !           190: .IR getsockopt ,
        !           191: this error may also be returned if
        !           192: .I optlen
        !           193: is not in a valid part of the process address space.
        !           194: .SH "SEE ALSO"
        !           195: ioctl(2), socket(2), getprotoent(3N)
        !           196: .SH BUGS
        !           197: Several of the socket options should be handled at lower levels of the system.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.