setsockopt(2dn)
NAME
setsockopt and getsockopt − set and get socket options
SYNTAX
#include <sys/types.h>
#include <sys/socket.h>
#include <netdnet/dn.h>
setsockopt (s,level,optname,optval,optlen)
int s,level,optname;
char *optval;
int optlen;
getsockopt (s,level,optname,optval,optlen)
int s,level,optname;
char *optval;
int *optlen;
ARGUMENTS
Input Arguments
s Specifies a descriptor for a socket in the AF_DECnet domain.
level Specifies the level at which options are interpreted:
A level of SOL_SOCKET causes options to be interpreted at the socket level.
You must use a level of DNPROTO_NSP to instruct the DECnet to interpret an option.
optname Specifies an option to be interpreted at the level specified.
optval, optlen Specify option values that are used with the setsockopt and getsockopt calls. The interpretations of these arguments relative to each call, are as follows:
setsockopt call
optval Specifies the address for the buffer that contains information for setting option values.
optlen Specifies the size of the option value buffer.
getsockopt call
optval Specifies the address of the buffer that will contain the returned value for the requested option.
optlen Value result parameter that initially contains the size of the buffer pointed to by optval and is modified on return to indicate the actual size of the returned value.
DESCRIPTION
The setsockopt and getsockopt calls manipulate various options associated with a socket. Options may exist at multiple levels, so you must specify the level for the desired operation.
The socket level (SOL_SOCKET) options are as follows:
SO_DEBUG
Enables the recording of debugging information.
SO_LINGER
Controls the actions taken when unsent messages are queued on a socket and a close call is issued. If SO_LINGER is set, the system will block the process until it is able to transmit the data or until it decides that it is unable to deliver the information.
At the DECnet level, socket options can define the way in which a pending connection is accepted. Options at this level also control the sending and receiving of optional user data and access control information, and return information on current link status. The DECnet options are as follows:
DSO_ACCEPTMODE
The accept mode option is used at the DECnet level for processing accept calls. A socket must issue a bind call before this option is valid. There are two values that can be supplied for this option: ACC_IMMED (immediate mode) and ACC_DEFER (deferred mode). (The optval for this option is of the type char.)
ACC_IMMED. ACC_IMMED mode is the default condition for this option. When immediate mode is in effect, control is immediately returned to a server program following an accept call with the connection request accepted.
ACC_DEFER ACC_DEFER mode enables a server program to complete an accept call without fully completing the connection to the client program. The server program can then examine the access control information, and optional data before accepting or rejecting the pending connection. The server program can then issue the setsockopt call with the appropriate reject or accept option.
DSO_CONACCEPT
DSO_CONACCEPT allows the server program to accept the connection on a socket returned by the accept call and previously set to ACC_DEFER mode. Any optional data previously set by DSO_CONDATA will be sent. (There is no accept call optval for this option.)
DSO_CONREJECT
DSO_CONREJECT lets the server program reject a pending connection on a socket returned by the accept call and previously set to ACC_DEFER mode. Any optional data previously set by DSO_DISDATA will be sent. The reject reason is passed with this option as a short int value.
DSO_CONDATA
This option allow up to 16 bytes of optional user data to be sent by the setsockopt call. It can be sent as a result of the connect or the accept (with the deferred option) calls. The optional data is passed in a structure of type optdata_on. (See Appendix ??? on how optdata_dn is formatted.) The data is read by the task issuing the getsockopt call with this option.
DSO_DISDATA DSO_DISDATA allows upt to 16 bytes of optional data to be set by the setsockopt call. It can be sent as a result of the close call. The optional data is passed in structure of type optdata_dn. (See Appendix ??? on how optdata_dn is formatted.) The data is read by the program issuing the getsockopt call with this option.
DSO_CONACCESS
DSO_CONACCESS allows access control information to be passed by the client program. This information is set with the setsockopt call. The access data is sent to the server program. It is passed with the connect call in a structure of type accessdata_dn. (See Appendix ??? on how accessdata_dn is formatted.) The access data is read by the program issuing the getsockopt call with this option.
The DSO_CONACCESS socket option for the getsockopt call will function only in programs running as root.
DSO_LINKINFO
Gets information on the state of a DECnet logical link. Link state information is passed in a structure of the type, linkinfo_dn in the field, idn_linkstate. The following are possible link states and their respective values:
LL_INACTIVE logical link inactive
LL_CONNECTING logical link connecting
LL_RUNNING logical link running
LL_DISCONNECTING logical link disconnecting
RETURN VALUE
If the call completes successfully, a value of 0 is returned. If the call fails, a value of −1 is returned and the external variable errno contains error details.
DIAGNOSTICS
[EBADF] The s argument is not a valid descriptor.
[ENOPROTOOPT] No access control information was supplied with the connection request.
[EFAULT] The options are not located in a valid part of the process address space.
[EOPNOTSUPP] The option is unknown.
[EMSGSIZE] The size of the option buffer is incorrect.
[ENOBUFS] No buffer space is available to return access control data.
[EBUSY] The pending connection has gone away.
[EDOM] The acceptance mode is not valid.