VMS Help
TCPIP Services, Programming Interfaces, Sockets API, setsockopt()
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
Sets options on a socket.
The $QIO equivalent is the IO$_SETMODE function.
Format
#include <types.h>
#include <socket.h>
int setsockopt ( int s, int level, int optname, char *optval,
int optlen );
s
A socket descriptor created by the socket() function.
level
The protocol level for which the socket options are to be
modified. It can have one of the following values:
SOL_SOCKET Set the options at the socket level.
p Any protocol number. Set the options for
protocol level p. See the IN.H header file
for the various IPPROTO values.
optname
Interpreted by the protocol specified in level. Options at each
protocol level are documented with the protocol.
Refer to:
o <REFERENCE>(op_setsock_tab) for a list of socket options
o <REFERENCE>(tcp_set_tab_opt) for a list of TCP options
o <REFERENCE>(ip_set_tab_opt) for a list of IP options
optval
Points to a buffer containing the arguments of the specified
option.
All socket-level options other than SO_LINGER should be nonzero
if the option is to be enabled, or zero if it is to be disabled.
SO_LINGER uses a linger structure argument defined in the
SOCKET.H header file. This structure specifies the desired state
of the option and the linger interval. The option value for the
SO_LINGER command is the address of a linger structure.
If the socket promises the reliable delivery of data and l_onoff
is nonzero, the system blocks the process on the close() attempt
until it is able to transmit the data or until it decides it is
unable to deliver the information. A timeout period, called the
linger interval, is specified in l_linger.
If l_onoff is set to zero and a close() is issued, the system
processes the close in a manner that allows the process to
continue as soon as possible.
optlen
An integer specifying the size of the buffer pointed to by
optval.
This function manipulates options associated with a socket.
Options can exist at multiple protocol levels. They are always
present at the uppermost socket level.
When manipulating socket options, specify the level at which the
option resides and the name of the option. To manipulate options
at the socket level, specify the value of level as SOL_SOCKET. To
manipulate options at any other level, supply the protocol number
of the appropriate protocol controlling the option. For example,
to indicate that an option is to be interpreted by TCP, set the
value for level argument to the protocol number (IPPROTO_TCP) of
TCP. See the IN.H header file for the various IPPROTO values.
0 Successful completion.
-1 Error; errno is set to indicate the error.
EACCES The calling process does not have appropriate
permissions.
EBADF The descriptor is invalid.
EDOM The send and receive timeout values are too
large to fit in the timeout fields of the
socket structure.
EINVAL The optlen argument is invalid.
EISCONN The socket is already connected; the specified
option cannot be set when the socket is in the
connected state.
EFAULT The optval argument is not in a readable part
of the user address space.
ENOBUFS The system had insufficient resources to
complete the call.
ENOPROTOOPT The option is unknown.
ENOTSOCK The socket descriptor is invalid.
EFAULT The optname argument is invalid.
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.