#include <sys.types.h>
#include <sys.socket.h>
#include <netinet.in.h> /* only for AF_INET or AF_INET6 */
Kernighan-Ritchie-C:
int getsockopt(s, level, optname, optval, optlen);
int s;
int level;
int optname;
char *optval;
int *optlen;
int setsockopt(s, level, optname, optval, optlen);
int s;
int level;
int optname;
char *optval;
int optlen;
ANSI-C:
int getsockopt(int s, int level, int optname, char* optval, int* optlen);
int setsockopt(int s, int level, int optname, char* optval, int optlen);
Description
The getsockopt() function can be used to get the properties (options) of the socket interface or of a single socket s via the optname, optval and optlen parameters.
The setsockopt() function can be used to set the properties (options) of the socket interface or of a single socket s via the optname, optval and optlen parameters.
You can use the level parameter to specify whether you want to get or set the options of the socket interface or of a single socket.
The following values are allowed as the current value for level:
Debugging outputs are enabled.
Get or set options of socket s of the AF_INET or AF_INET6 address family.
Get or set options of socket s of the AF_ISO address family.
Get or set options of socket s in the AF_INET or AF_INET6 address family for modifying the protocol behavior of the TCP protocol.
Get or set options of socket s in the AF_INET address family for modifying the protocol behavior of the IPv4 protocol. For reasons of compatibility, both IPPROTO_IP and IPPROTO_IPV4 are evaluated.
Query or modify options for the socket s in the address family AF_INET6 for modifying the behavior of the IP protocol.
Query or modify options for the socket s in the address family AF_INET of the type SOCK_RAW for modifying the protocol behavior of the IP protocol in conjunction with the ICMP protocol.
Query or modify options for the socket s in the address family AF_INET6 of the type SOCK_RAW for modifying the protocol behavior of the IP protocol in conjunction with the ICMPv6 protocol.
A bind() is neccessary for some of the options with level = IPPROTO_IPV4 and IPPROTO_IPV6.
Options for the SOL_GLOBAL level
At SOL_GLOBAL level operand s is meaningless and should be assigned the value 0.
optname = SO_DEBUG enables debugging outputs with verious depths of detail to be enabled.
With getsockopt() and optlen with a value of 4 (sizeof int), the value of the debugging output level currently set is output in optval.
The value 0 disables the debugging output.
With setsockopt() and optlen with a value of 4, the following debugging output level shown in the table below can be specified in optval
*optval >= 1: Function calls | ||
*optval >= 6: Function calls | + additional information | |
*optval = 8: Function calls | + additional information | BCAM parameter area after call |
*optval = 9: Function calls | + additional information | + BCAM parameter area after call |
With setsockopt() and optname = SO_ASYNC and optlen = 4 and optval with a pointer to the short ID of the event ID of the external bourse to be used, an external wait point is configured for SOCKETS(BS2000) when this is the first socket call of the subsystem (see chapter "setsockopt() - modify socket options").
optname | *optlen | Value range of optval |
SO_ASYNC | 4 | Pointer to short ID of the event ID |
Options for the SOL_SOCKET (AF_INET, AF_INET6) level
In this case, s specifies the socket for which the options are to be retrieved or set, and optname specifies the name of the option for which a value is to be retrieved or set.
With getsockopt(), optval and optlen identify the respective buffers in which the value of the desired option is returned. *optlen initially contains the size of the buffer to which optval points. When the getsockopt() function returns, *optlen contains the current size of the returned buffer. If the option in question has no value that can be returned, *optval contains the value 0.
The following values can be returned by getsockopt() for optname and optlen in the AF_INET and AF_INET6 address families:
optname | * optlen | Output format in optval |
SO_DEBUG | 4 | int |
SO_DISHALIAS | 4 | int |
SO_ERROR | 4 | int |
SO_KEEPALIVE | 4 | int |
SO_LINGER | >= sizeof(struct linger) | *(struct linger) |
SO_OUTPUTBUFFER | 4 | int |
SO_RCVBUF | 4 | int |
SO_SNDBUF | 4 | int |
SO_TIMESTAMP | 4 | int |
SO_TSTIPAD | 4 | int |
SO_TYPE | 4 | int |
SO_VHOSTANY | 8 | *(char[8]) |
SO_KEEPALIVE
An output value >0 specifies that a timer value has been set with setsockopt(). The caller cannot recognize the connection status for the selected socket. If the connection is active, the timer value is determined by BCAM from the connection information. If the connection is not yet active, the timer value is read from the socket.
If a timer value = 0 is output, this does not necessarily mean that KEEPALIVE is disabled! A global setting of the KEEPALIVE timer by the BCAM administration cannot be seen by means of this function.
The setsockopt() function can be used to set or change option values via the optval and optlen parameters. You can specify the following values for optname, optlen and optval in the AF_INET and AF_INET6 address families:
optname | optlen | optval |
SO_BROADCAST (only AF_INET) | 4 | |
SO_DEBUG | 4 | 0 |
SO_DISHALIAS | 4 | 0, 1 |
SO_KEEPALIVE | 4 | 0; 120...32767 |
SO_LINGER | >= sizeof(struct linger) | *(struct linger) |
SO_REUSEADDR | 4 | 0, 1 |
SO_TIMESTAMP | 4 | 0, 1 |
SO_VHOSTANY | 4 | *(char[9]) |
The valid value range of optval for the SO_KEEPALIVE option is 0 and 120 ... 32767:
If the value is 0, the timer is switched off.
If the value is in the range of 120 ... 32767, the timer is switched on and the timer interval is set with the specified value (unit of measurement: seconds).
If a value outside the valid range is specified, the timer interval is set with the default value of the transport system.
SO_BROADCAST (only AF_INET)
This option has no functional meaning for sockets. Only a syntax check is performed.
If the syntax is valid, the value 0 is returned; otherwise, -1.
SO_DEBUG
If level = SOL_GLOBAL, this option defines the debugging level for the sockets of the active task.
If level = SOL_SOCKET, this option has no functional significance; only a syntax check is performed.
If the syntax is valid, the value 0 is returned; otherwise, -1.
SO_DISHALIAS
A value >0 makes an entry in the socket that host aliasing is to be deactivated for this application with the bind() call.
SO_ERROR
Shows the number of the last error issued.
SO_KEEPALIVE
Specifies whether TCP-KEEPALIVE monitoring is to be performed on this connection.
In particular it specifies:
Whether KEEPALIVE monitoring should be activated in the TCP protocol machine for the current connection.
Which time interval (in seconds) should be selected for this monitoring.
The effect of SO_KEEPALIVE depends on the status of the corresponding socket:
If an active connection is not established for the socket, the desire to activate KEEPALIVE monitoring with the corresponding value of the timer interval is noted in the socket structure and transferred to the transport system when a connection is established.
With a server application, i.e. in the case of a passive connection establishment, the active listen() socket must be executed with SO_KEEPALIVE, so that monitoring is automatically switched on every time a connection is established.
If an active connection already exists for the socket, the information is transmitted to the TCP protocol machine using an internal transport system call.
If the time interval value is 0, monitoring is deactivated:
If a connection already exists, monitoring is deactivated immediately.
If no connection exists, monitoring is deactivated when a connection is established. With the server, the listen() socket must be marked accordingly.
Due to the various ways in which TCP protocol machines are implemented, it cannot be guaranteed that the connections are maintained (see also RFC 1122).
SO_LINGER
The SO_LINGER option uses a parameter of data type struct linger. This parameter specifies the desired option status and the delay interval.
The linger structure is defined in <sys.socket.h>. The current option status and delay interval can be obtained through a linger structure via getsockopt().
struct linger { int l_onoff; /* option on/off */ int l_linger; /* linger time */ };
The l_linger parameter specifies the maximum time for executing soc_close(), l_onoff activates and deactivates the linger function (0 = OFF, >0 = ON).
SO_OUTPUTBUFFER
Shows the user data accepted by the socket interface but not yet acknowledged by the partner transport system.
SO_RCVBUF
Shows the size of the receive (input) buffer.
SO_REUSEADDR
This option has no functional significance if the application was produced with SOCKETS(BS2000) version <= V2.1 or encounters BCAM < V18 ; only a syntax check is performed.
If the application was produced as of SOCKETS(BS2000) V.2.2 then the SO_REUSEADDR functionality is required as part of multihoming support. SO_REUSEADDR only affects the specified socket and must be set before bind().
SO_REUSEADDR is set with optval = 1 and reset with optval = 0.
If the syntax is valid, the value 0 is returned; otherwise, -1.
SO_SNDBUF
Shows the size of the send (output) buffer.
SO_TIMESTAMP
all packets received via recvmsg() obtain a timestamp, which is saved in a cmsghdr structure. The cmsg_data field of this structure is a struct timeval indicating the reception time of the received packet.
The timeval structure is defined in <sys.time.h>.
struct timeval { long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ };
SO_TIMESTAMP is activated by setting optval = 1 and deactivated by setting optval = 0. SO_TIMESTAMP is deactivated by default.
Return value of SO_TIMESTAMP:
0: The flag is not set
1: The flag is set
SO_TSTIPAD
Compares the transferred IP address with the interface addresses of the socket host, on which the socket application runs. SO_TSTIPAD reports the comparison result via optval.
The IP address is transferred as an IPv4 or IPv6 address via the optval pointer that points to a struct in_addr or struct in6_addr structure.
The specified socket may not exist. However, the file descriptor must be in the permitted value range.
The value of the optlen parameter specifies whether it is an IPv4 or IPv6 address. Therefore the value of optlen must correspond to the length of struct in_addr or struct in6_addr depending on the address type used.
When used as a return value the first 4 bytes of the address structure passed at the call are overwritten.
Return value of optval:
0: The specified IP address is a separate interface address.
1: The specified IP address is not a separate interface address.
SO_TYPE
Shows the socket type.
SO_VHOSTANY
The BCAM host name of the real or virtual host is specified in the string pointed to by optval. This is then entered in the socket.
This makes it possible to address a virtual host with an ANYADDR or LOOPBACKADDR or to read the data from a virtual host with soc_ioctl(...,SIOCGLIFCONF,....). It is also possible to address a real host if you are working under an ID assigned to a virtual host by an entry in the BCAM application table.
The name of the BCAM host as entered in the socket is output on reading.
BCAM host name:
The name is eight characters in length. Alphanumeric characters and the special characters #, @, $ or blanks can be used at the end of the name. As a rule, uppercase characters should be used, but the name is case-sensitive. Names comprising numeric characters only are not permitted.
Options for the IPPROTO_IPV4 (AF_INET) level
The getsockopt() function can be used to specify the following values for optname and optlen in the AF_INET address family:
optname | * optlen | Output format in optval |
IP_MTU_DISCOVER | 4 | int |
IP_MULTICAST_TTL | 4 | int |
IP_MULTICAST_IF | >= sizeof(struct in_addr) | *(struct in_addr) |
IP_MULTICAST_LOOP | 4 | int |
IP_OPTIONS | 8..40 | char* |
IP_RECVERR | 4 | int |
IP_RECVTTL | 4 | int |
IP_TTL | 4 | int |
Return value of IP_MTU_DISCOVER:
0: IP_PMTUDISC_DONT
2: IP_PMTUDISC_DO
Return value of IP_MULTICAST_TTL and IP_TTL:
Value of the selected hop limit.
The bind()-function has to be called before setting IP_MULTICAST_TTL.
Return value of IP_MULTICAST_IF:
IPv4 address of the interface to be used for sending.
The bind()-function has to be called before setting this option.
Return value of IP_MULTICAST_LOOP:
0: Loopback OFF
1: Loopback ON
The bind()-function has to be called before setting this option.
Return value of IP_OPTIONS:
The internet options set by the sender are returned in the same format as they were put in. The length has to be at least as big as the size of the internet options.
Return value of IP_RECVERR and IP_RECVTTL:
0: The flag is not set
1: The flag is set
The setsockopt() can be used to modify option values via the optval() and optlen() parameters. You can specify the following values in the AF_INET address family:
optname | optlen | optval |
IP_ADD_MEMBERSHIP | >= sizeof(struct ip_mreq) | *(struct ip_mreq) |
IP_DROP_MEMBERSHIP | >= sizeof(struct ip_mreq) | *(struct ip_mreq) |
IP_MTU_DISCOVER | 4 | IP_PMTUDISC_DO IP_PMTUDISC_DONT |
IP_MULTICAST_TTL | 4 |
|
IP_MULTICAST_IF | >= sizeof(struct in_addr) | *(struct in_addr) |
IP_MULTICAST_LOOP | 4 | >= 0 |
IP_OPTIONS | <=40 | char* |
IP_RECVERR | 4 | >= 0 |
IP_RECVTTL | 4 | 0, 1 |
IP_TTL | 4 | 1..255 |
The IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP options use a parameter of the type struct ip_mreq. This parameter specifies the IPv4 address of the desired multicast group and the local IPv4 address.
The ip_mreq structure is defined in <netinet.in.h>.
struct ip_mreq { struct in_addr imr_multiaddr; /* IP multicast address of group */ struct in_addr imr_interface; /* local IP address of interface */ };
IP_MULTICAST_TTL
Shows or sets the multicast hop limit.
The bind()-function has to be called before setting this option.
Hop limit values:
0: Send only within the local host (loopback)
1: Send within the local subnetwork
>1: Send beyond router boundaries
IP_ADD_MEMBERSHIP
Activates the delivery of messages of a selected multicast group to this socket.Specifies the multicast or local interface address (IPv4 address or INADDR_ANY, not INADDR_LOOPBACK).
INADDR_ANY is the default interface of BCAM for receiving multicast data.
The bind()-function has to be called before setting this option.
IP_DROP_MEMBERSHIP
Deactivates delivery of messages of a selected multicast group to this socket. Specifies the multicast and local interface addresses (IPv4 address or INADDR_ANY, not INADDR_LOOPBACK).
INADDR_ANY is the default interface of BCAM for receiving multicast data.
The bind()-function has to be called before setting this option.
IP_MTU_DISCOVER
Sets the DF flag in the IPv4 protocol header which permits or prevents fragmentation of an ICMP or UDP packet.
IP_PMTUDISC_DONT | Fragmentation permitted |
IP_PMTUDISC_DO | Fragmentation is to be prevented |
IP_MULTICAST_IF
IPv4 address of the interface over which transfer is to take place.
The bind()-function has to be called before setting this option.
IP_MULTICAST_LOOP
Is set by the sender of the messages and enables reception on the local sending host.0: OFF, 1: ON (default: ON)
The bind()-function has to be called before setting this option.
IP_OPTIONS
Internet options that can be set by the sender of the messages. The received char-pointer has to be aligned to a 4-byte-boundary. The exact format of the Internet options can be seen in the RFC791 at chapter 3.1. Currently, only Loose Source Route, Strict Source Route, Record Route and the Timestamp Option are supported by Sockets.
IP_RECVERR
Activates the delivery of ICMP error messages to this socket if the option was set before bind(). The error reports for datagram and raw sockets are fetched with using recvmsg() and the flag MSG_ERRQUEUE.
IP_RECVTTL
the TTL-field from every IPV4-packet received via recvmsg() is read out and saved in a cmsghdr structure.
IP_RECVTTL is activated by setting optval = 1 and deactivated by setting optval = 0. IP_RECVTTL is deactivated by default.
IP_TTL
Modifies the hop limit in the corresponding field of the packet’s IP protocol header.
Options for the IPPROTO_IPV6 (AF_INET6) level
In the case of getsockopt(), you can enter the following values for optname and optlen in the address family AF_INET6:
optname | * optlen | Output format of optval |
IPV6_HOPLIMIT | 4 | int |
IPV6_MTU_DISCOVER | 4 | int |
IPV6_MULTICAST_HOPS | 4 | int |
IPV6_MULTICAST_IF | 4 | int |
IPV6_MULTICAST_LOOP | 4 | int |
IPV6_RECVERR | 4 | int |
IPV6_RECVHOPLIMIT | 4 | int |
IPV6_UNICAST_HOPS | 4 | int |
IPV6_V6ONLY | 4 | int |
Return value of IPV6_MTU_DISCOVER:
0: IP_PMTUDISC_DONT
2: IP_PMTUDISC_DO
Return value of IPV6_MULTICAST_HOPS, IPV6_UNICAST_HOPS and IPV6_HOPLIMIT:
Value of the selected hop limit.
The bind()-function has to be called before setting IPV6_MULTICAST_HOPS or IPV6_UNICAST_HOPS.
Return value of IPV6_MULTICAST_IF:
Index of the sender interface.
The bind()-function has to be called before setting this option.
Return value of IPV6_MULTICAST_LOOP:
0: Loopback OFF
1: Loopback ON
The bind()-function has to be called before setting this option.
Return value of IPV6_RECVERR, IPV6_RECVHOPLIMIT and IPV6_V6ONLY:
0: The flag is not set
1: The flag is set
In the case of setsockopt(), you can enter the following values for optname and optlen in the address family AF_INET6:
optname | optlen | optval |
IPV6_JOIN_GROUP | >= sizeof(struct ipv6_mreq) | *(struct ipv6_mreq) |
IPV6_LEAVE_GROUP | >= sizeof(struct ipv6_mreq) | *(struct ipv6_mreq) |
IPV6_HOPLIMIT | 4 | 1..255 |
IPV6_MTU_DISCOVER | 4 | IP_PMTUDISC_DO IP_PMTUDISC_DONT |
IPV6_MULTICAST_HOPS | 4 | 0..255 |
IPV6_MULTICAST_IF | 4 | 1..255 |
IPV6_MULTICAST_LOOP | 4 | >= 0 |
IPV6_RECVERR | 4 | >= 0 |
IPV6_RECVHOPLIMIT | 4 | 0, 1 |
IPV6_UNICAST_HOPS | 4 | 0..255 |
IPV6_V6ONLY | 4 | >= 0 |
The IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP options use a parameter of the data type struct ipv6_mreq. This parameter specifies the IPv6 address of the required multicast group and the index of the local interface.
The ipv6_mreq structure is defined in <netinet.in.h>:
struct ipv6_mreq { struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast addr */ int ipv6mr_interface; /* interface index */ };
IPV6_HOPLIMIT
Modifies the hop limit in the corresponding field of the packet’s IPv6 protocol Header.
IPV6_MULTICAST_HOPS
Displays or sets the multicast hop limit.
The bind()-function has to be called before setting this option.
Hop limit values:
0: Send only within the local host (loopback)
1: Send within the local subnetwork
>1: Send beyond router boundaries
IPV6_JOIN_GROUP
Activates the delivery of messages of a selected multicast group to this socket. Specifies the IPv6 multicast address and the index of the local interface address (index for IPv6 address or index 0, no index for loopback).
Index 0 stands for the default interface of BCAM for receiving multicast data.
The bind()-function has to be called before setting this option.
IPV6_LEAVE_GROUP
Deactivates the delivery of messages of a selected multicast group to this socket. Specifies the IPv6 multicast address and the index of the local interface address (index for IPv6 address or index 0, no index for loopback).
Index 0 stands for the default interface of BCAM for receiving multicast data.
The bind()-function has to be called before setting this option.
IPV6_MTU_DISCOVER
IP_PMTUDISC_DONT | Fragmentation permitted |
IP_PMTUDISC_DO | Fragmentation is to be prevented |
This function has no effect because on the IPv6 protocol level, in contrast to IPv4, no flag is envisaged which could prevent fragmentation. The end systems are obliged to perform fragmentation by the IPv6 protocol definition.
IPV6_MULTICAST_IF
Index of the IPv6 interface over which transfer is to take place.
The bind()-function has to be called before setting this option.
IPV6_MULTICAST_LOOP
Is set by the sender of the messages and enables reception on the local sending host.0: OFF, 1: ON (default: ON)
The bind()-function has to be called before setting this option.
IPV6_RECVERR
Activates the delivery of ICMP error messages to this socket if the option was set before bind(). The error reports for datagram and raw sockets are fetched with using recvmsg() and the flag MSG_ERRQUEUE.
IPV6_RECVHOPLIMIT
The hop limit field from every IPV6-packet received via recvmsg() is read out and saved in a cmsghdr structure.
IPV6_RECVHOPLIMIT is activated by setting optval = 1 and deactivated by setting optval = 0. IPV6_RECVHOPLIMIT is deactivated by default.
IPV6_UNICAST_HOPS
Sets the unicast hop limit.
The bind()-function has to be called before setting this option.
Hop limit values:
0: Send only within the local host (loopback)
1: Send within the local subnetwork
>1: Send beyond router boundaries
IPV6_V6ONLY
Using the IPV6_V6ONLY option, it is possible to restrict a socket to the use of genuine IPv6 addresses (optval >=1) if it is set ahead of bind() in the socket. This makes it possible to provide server applications which open a listen socket in the domains AF_INET and AF_INET6 using the same port number.
Options for the IPPROTO_TCP (AF_INET, AF_INET6) level
Calling the getsockopt() function you can specify the following values for optname and optlen in the AF_INET and AF_INET6 address families:
optname | * optlen | Output format in optval |
SO_TCP_NODELAY | 4 | int |
The setsockopt() function can be used to modify option values via the optval() and optlen() parameters. You can specify the following values in the AF_INET and AF_INET6 address families:
optname | optlen | optval |
SO_TCP_NODELAY | 4 | 1 or 0 (reset/set) |
TCP_DELAY | 4 | 1 or 0 (reset/set) |
SO_TCP_NODELAY (TCP_NODELAY)
Allows the Nagle algorithm of the TCP protocol to be deactivated. If this option is set in the socket (connect() or listen()), the action is activated on connect() or when the connection is acknowledged.
If the connection has already been established, the option takes effect immediately.
TCP_DELAY
Enable or disable the Delayed-Ack timer for a connection. If optval >0, delayed acknowledgements are disabled and if optval = 0, they are enabled again.
The connection must have been established.
Options for the IPPROTO_ICMP (AF_INET) level
In the case of setsockopt(), you can modify option values using the optval() and optlen() parameters. You can specify the following values in the AF_INET address family:
optname | optlen | optval |
IP_TTL | 4 | 1...255 |
IP_MTU_DISCOVER | 4 | IP_PMTUDISC_DO |
IP_TTL
Modifies the hop limit in the corresponding field of the ICMP echo request packet’s IP protocol header.
IP_MTU_DISCOVER
Sets the DF flag in the IPv4 protocol header which permits or prevents fragmentation of an ICMP echo request packet.
IP_PMTUDISC_DONT | Fragmentation permitted |
IP_PMTUDISC_DO | Fragmentation is to be prevented |
Options for the IPPROTO_ICMPV6 (AF_INET6) level
In the case of setsockopt(), you can modify option values using the optval() and optlen() parameters. You can specify the following values in the AF_INET6 address family:
optname | optlen | Output format in optval |
IPV6_HOPLIMIT | 4 | 1...255 |
IPV6_MTU_DISCOVER | 4 | IP_PMTUDISC_DO |
IPV6_HOPLIMIT
Modifies the hop limit in the corresponding field of the ICMPv6 echo request packet’s IPv6 protocol header.
IPV6_MTU_DISCOVER
IP_PMTUDISC_DONT | Fragmentation permitted |
IP_PMTUDISC_DO | Fragmentation is to be prevented |
This function has no effect because on the IPv6 protocol level, in contrast to IPv4, no flag is envisaged which could prevent fragmentation. The end systems are obliged to perform fragmentation by the IPv6 protocol definition.
Options for the SOL_TRANSPORT level (only for AF_ISO)
In this case, s specifies the socket for which the options are to be retrieved or set, and optname specifies the name of the option for which a value is to be retrieved or set.
With getsockopt(), optval and optlen identify the respective buffers in which the value of the desired option is returned. *optlen initially contains the size of the buffer to which optval points. When the getsockopt() function returns, *optlen contains the current size of the returned buffer. If the option in question has no value that can be returned, *optval contains the value 0.
The following values can be returned by getsockopt() for optname and *optlen in the AF_ISO address family:
optname | * optlen | Output format in optval |
TPOPT_CONN_DATA | 0..33 | string incl. null byte |
TPOPT_CFRM_DATA | 0..33 | string incl. null byte |
TPOPT_DISC_DATA | 0..33 | string incl. null byte |
TPOPT_REDI_CALL | sizeof(struct cmsg_redhdr) | struct cmsg_redhdr |
The actual length of the connection data is specified in *optlen. The value range for optlen is 0..33 since the maximum length of the connection data is 32 bytes.
setsockopt() can be used in the AF_ISO address family to write connection data to the socket depending on the socket status. The options described below are known on the socket level.
Description of the socket options for AF_ISO:
TPOPT_CONN_DATA
The socket s has been created and has received an address with bind(), but connect() has not yet been executed:
You can enter the connection data to be sent to the partner when connect() is called in the socket s by using TPOPT_CONN_DATA as the current parameter value for optname.
TPOPT_CFRM_DATA
A connection request is received for the socket s, and the socket s has not yet accepted it:
You can enter the connection data to be sent for accepting the connection to the partner in the socket s by using TPOPT_CFRM_DATA as the current parameter value for optname (see also figure 4 in section "Interaction between functions for connection-oriented communications").
TPOPT_DISC_DATA
The connection to the partner socket has been set up completely:
You can enter the connection data to be sent to the partner for soc_close() in the socket s by using TPOPT_DISC_DATA as the current parameter value for optname.
The actual length of the connection data is specified in *optlen. The value range for optlen is 1..32 since the maximum length of the connection data is 32 bytes and the minimum length is 1 byte.
TPOPT_REDI_CALL
This is required for the handoff procedure (see chapter "Extended SOCKETS(BS2000) functions").
Return value
0:
If successful.
-1:
If errors occur. errno is set to indicate the error.
Errors indicated by errno
ENOPROTOOPT
The option is not supported by the protocol, or
an invalid value was specified for level, optname, optvalue or optlen.
ENOTSOCK
Descriptor s does not point to a socket.
See also
socket()