Returns the options set on a socket.
Format
#include <socket.h>
int getsockopt (int s, int level, int
optname, char *optval, int
*optlen);
Arguments
- s
- A socket descriptor created by socket.
- level
- The protocol level for which the socket options are desired. It
may have one of the following values:
SOL_SOCKET | Get the options at the socket
level. |
p | Any protocol
number. Get the options for protocol level p. See the <in.h>
file for the various IPPROTO values. |
- optname
- Is interpreted by the protocol that is specified in the level.
Options at each protocol level are documented with the protocol. See
setsockopt in this section for socket level options.
- optval
- Points to a buffer in which the value of the specified option
should be placed by getsockopt.
- optlen
- Points to an integer containing the size of the buffer pointed
to by optval. On return, the integer will be modified to
contain the actual size of the option value returned.
Description
This routine gets information on socket options. See the
appropriate protocol for information on available options at each
protocol level.
Return Values
0 | Indicates success. |
-1 | Indicates an error; errno is set to one
of the following:
- EBADF - The descriptor is invalid.
- ENOTSOCK - The socket descriptor references a file, not a
socket.
- ENOPROTOOPT - The option is unknown or the protocol is
unsupported.
|
Previous Page | Next Page | Table of Contents | Index