getsockopt.2

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 120 行

2
120
字号
.\" SCCSID: @(#)getsockopt.2	6.1	4/27/89.TH getsockopt 2.SH Namegetsockopt, setsockopt \- get or set options on sockets.SH Syntax.nf.B #include <sys/types.h>.B #include <sys/socket.h>.sp .5.B getsockopt(s, level, optname, optval, optlen).B int s, level, optname;.B char *optval;.B int *optlen;.sp.B setsockopt(s, level, optname, optval, optlen).B int s, level, optname;.B char *optval;.B int optlen;.fi.SH Description.NXR "getsockopt system call".NXR "setsockopt system call".NXR "socket" "getting options".NXR "socket" "setting options"The.PN getsockoptand.PN setsockoptsystem calls manipulate optionsassociated with a socket.  Options can exist at multipleprotocol levels; they are always present at the uppermostsocket level..PPWhen manipulating socket options, the level at which theoption resides and the name of the option must be specified.To manipulate options at the socket level,.I levelis specified as SOL_SOCKET.  To manipulate options at anyother level, the protocol number of the appropriate protocolcontrolling the option must be supplied.  For example,to indicate an option is to be interpreted by the TCP protocol,.I levelshould be set to the protocol number of TCP.  For furtherinformation, see .MS getprotoent 3n ..PPThe parameters.I optvaland.I optlenare used to access option values for.PN setsockopt .For.PN getsockopt ,they identify a buffer in which the values for therequested options are to be returned.  For.PN getsockopt ,.I optlenis a value-result parameter, initially containing thesize of the buffer pointed to by.IR optval and modified on return to indicate the actual size ofthe value returned.  If no option value isto be supplied or returned,.I optvalcan be supplied as 0..PPThe.I optnameparameter and any specified options are passed uninterpreted to the appropriateprotocol module for interpretation.The include file <sys/socket.h>contains definitions for socket level options.For further information, see .MS socket 2 .Options at other protocol levels vary in format andname.  Consult the .MS arp 4p ,.MS ip 4p ,.MS tcp 4por.MS udp 4p reference pages for details..SH Return ValuesA zero is returned if the call succeeds, and \-1 is returned if it fails..SH DiagnosticsThe .PN getsockoptcall fails under the following conditions:.TP 15[EBADF]The argument .I sis not a valid descriptor..br.ne 2.TP 15[ENOTSOCK]The argument .I sis a file, not a socket..TP 15[ENOPROTOOPT]The option is unknown..TP 15[EFAULT]The address pointed to by.I optvalis not in a valid part of theprocess address space.For.PN getsockopt ,this error can also be returned if.I optlenis not in a valid part of the process address space..SH See Alsofcntl(2), socket(2), getprotoent(3n),.I "Guide to the Data Link Interface"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?