The SockGetSockOpt() call gets the socket options associated with a socket.
Syntax:
>>--SockGetSockOpt(socket, level, optName, optVal)-----------------------><
where:
is the socket descriptor.
specifies which option level is queried for the specified optname. The only supported level is SOL_SOCKET.
is the name of the specified socket option. Only one option can be specified with a call.
is the variable to receive the option values requested. For socket options that are Boolean the option is enabled if optval is nonzero and disabled if optval is 0.
SockGetSockOpt() returns the value of a socket option at the socket level. It can be requested for sockets of all domain types. Some options are supported only for specific socket types.
The following options are recognized for SOL_SOCKET:
returns the information whether datagram sockets are able to broadcast messages. If this option is enabled, the application can send broadcast messages using datagram socket, if the interface specified in the destination supports broadcasting of packets.
returns the information whether debug information can be recorded for a socket.
returns the information whether the socket is able to bypass the routing of outgoing messages. If this option is enabled, outgoing messages are directed to the network interface specified in the network portion of the destination address. When enabled, packets can only be sent to directly connected networks.
returns any error pending at the socket and clears the error status. It can be used to check for asynchronous errors at connected datagram sockets or for asynchronous errors that are not explicitly returned by one of the socket calls.
returns the information whether stream sockets are able to send keepalive packets. TCP uses a timer called the keepalive timer. This timer monitors idle connections that might have been disconnected because of a peer crash or timeout. If this option is enabled, a keepalive packet is periodically sent to the peer.
This option is mainly used to enable servers to close connections that are no longer active as a result of clients ending connections without properly closing them.
returns the information whether stream sockets are able to linger on close if data is present. If this option is enabled and there is data still to be sent when SockSoClose() is called, the calling application is blocked during the SockSoClose() call until the data is transmitted or the connection has timed out. If this option is disabled, the SockSoClose() call returns without blocking the caller while TCP is trying to send the data. Although the data transfer is usually successful, it cannot be guaranteed because TCP tries to send the data only for a specific amount of time.
returns the information whether stream sockets are able to receive out-of-band data. If this option is enabled, out-of-band data is placed in the normal data input queue as it is received. It is then made available to SockRecv() and SockRecvFrom() without the MSG_OOB flag being specified in those calls. If this option is disabled, out-of-band data is placed in the priority data input queue as it is received. It can then only be made available to SockRecv() and SockRecvFrom() by specifying the MSG_OOB flag in those calls.
returns the buffer size for input.
returns the receive low-water mark.
returns the timeout value for a receive operation.
returns the information whether stream and datagram sockets are able to reuse local addresses. If this option is enabled, the local addresses that are already in use can then be bound. This alters the normal algorithm used in the SockBind() call. At connection time, the system checks whether the local addresses and ports differ from foreign addresses and ports. If not, the error value EADDRINUSE is returned.
returns the size of the send buffer.
returns the send low-water mark. This mark is ignored for nonblocking calls and not used in the Internet domain.
returns the timeout value for a send operation.
returns the socket type. The integer pointed to by optval is then set to one of the following: STREAM, DGRAM, RAW, or UNKNOWN.
bypasses hardware where possible.
All option values are integral except for SO_LINGER, which contains the following blank-delimited integers:
The l_onoff value. It is set to 0 if the SO_LINGER option is disabled.
The l_linger value. It specifies the amount of time, in seconds, to be lingered on close. A value of 0 causes SockSoClose() to wait until disconnection completes.
Return values:
The value 0 indicates successful execution of the call. The value -1 indicates an error. You can get the specific error code by calling SockSock_Errno() or SockPSock_Errno(). Possible values are:
The address is already in use.
socket is not a valid socket descriptor.
optname or level is not recognized.
Note: SockGetSockOpt() interfaces with the C function getsockopt().