The getsockopt() call gets options associated with a socket;
setsockopt() sets the options.
The following options are recognized at the IPPROTO_IP
level:
- Joining a multicast group
- Leaving a multicast group or leaving all sources for a given
multicast group
- Setting the multicast interface
- Setting the IP time-to-live of outgoing multicast datagrams
- Looping back multicast datagrams
- Joining a source-specific multicast group
- Leaving a source-specific multicast group
- Blocking data from a given source to a given multicast group
- Unblocking a previously blocked source for a given multicast group
The following options are recognized at the IPPROTO_IPV6
level:
- Joining a multicast group
- Leaving a multicast group
- Setting the multicast interface
- Setting multicast hop limit
- Looping back multicast datagrams
- Setting unicast hop limit
- Restricting sockets to AF_INET6 sockets
- Setting source IP address selection preferences
- Retrieving source IP address selection preferences
The following options are recognized at the IPPROTO_IP
and IPPROTO_IPV6 level:
- Joining an IPv4 or IPv6 multicast group
- Leaving an IPv4 or IPv6 multicast group or leaving all sources
for a given IPv4 or IPv6 multicast group
- Joining an IPv4 or IPv6 source-specific multicast group
- Leaving an IPv4 or IPv6 source-specific multicast group
- Blocking IPv4 or IPv6 data from a given source to a given multicast
group
- Unblocking an IPv4 or IPv6 previously blocked source for a given
multicast group
The following options are recognized at the socket level:
- Broadcasting messages (IPv4 UDP socket only)
- Toggling the TCP keep-alive mechanism for a stream socket
- Lingering on close if data is present
- Receiving of out-of-band data
- Local address reuse
- Prevent
infinite blocking for receive and send type functions
The following option is recognized at the TCP level (IPPROTO_TCP):
- Disable sending small data amounts until acknowledgment (Nagle
algorithm)
As well as checking current options, getsockopt() can
return pending errors and the type of socket.