![Texas TMS320C6000 Programmer'S Reference Manual Download Page 63](http://html.mh-extra.com/html/texas/tms320c6000/tms320c6000_programmers-reference-manual_1093844063.webp)
Sockets Programming Interfaces
3-31
Sockets and Stream IO API
Get the Value of a Socket Option Parameter
setsockopt
Syntax
int setsockopt( int s, int level, int op, void *pbuf, int bufsize );
Parameter(s)
s
Socket
level
Option level (SOL_SOCKET, IPPROTO_IP, IPPROTO_TCP)
op
Socket option to get
pbuf
Pointer to memory buffer
bufsize
Size of memory buffer pointed to by pbuf
Return Value
If it succeeds, the function returns 0. Otherwise, a value of –1 is returned and
the function fdError() can be called to determine the error:
EBADF
The file descriptor (socket) is invalid.
ENOTSOCK
The file descriptor does not reference a socket.
EINVAL
Buffer arguments are invalid.
Description
The setsockopt() function sets option values associated with a socket. Options
may exist at multiple protocol levels; they are always present at the uppermost
socket level.
When manipulating socket options, the level at which the option resides and
the name of the option must be specified. To manipulate options at the socket
level, level is specified as SOL_SOCKET. To manipulate options at any other
level the protocol number of the appropriate protocol controlling the option is
supplied. In this implementation, only SOL_SOCKET, IPPROTO_IP, and
IPROTO_TCP are supported.
The parameters pbuf and bufsize identify a buffer which holds the value for the
specified option.
Most socket-level options utilize an int parameter for pbuf. SO_LINGER uses
a struct linger parameter, defined in INC\SOCKET.H, which specifies the de-
sired state of the option and the linger interval (see below). SO_SNDTIMEO
and SO_RCVTIMEO use a struct timeval parameter.
The socket options supported for setsockopt() are the same as defined for get-
sockopt() with the exception of SO_TYPE and SO_ERROR, which can not be
set.
Please see the description of getsockopt() for a list of socket options.