SOSetSockOpt


C Specification

#include <dolphin/socket.h>
int SOSetSockOpt ( int s, int level, int optname,
                   const void* optval, int optlen );

Description

SOSetSockOpt() sets the socket options. The supported options are summarized in the following table:

Level Option name Type TCP UDP Description
SO_SOL_SOCKET SO_SO_REUSEADDR BOOL

•

• Allows reuse of the local address.
SO_SOL_SOCKET SO_SO_OOBINLINE BOOL •   Receives urgent byte in band.
SO_SOL_SOCKET SO_SO_LINGER SOLinger •   Lingers on a close when data exist.
SO_SOL_SOCKET SO_SO_SNDBUF int • • The socket send buffer size in bytes.
SO_SOL_SOCKET SO_SO_RCVBUF int • • The socket receive buffer size in bytes.
SO_SOL_SOCKET SO_SO_SNDLOWAT int •   The send low water mark in bytes (default: 1).
SO_SOL_SOCKET SO_SO_RCVLOWAT int •   The receive low water mark in bytes (default: 1).
SO_SOL_IP SO_IP_TOS int • • Type of service.
SO_SOL_IP SO_IP_TTL int • • Time to live.
SO_SOL_IP SO_IP_MULTICAST_LOOP u8 • • Loops back multicast datagrams (default: enabled).
SO_SOL_IP SO_IP_MULTICAST_TTL u8 • • Time to live set to multicast datagrams (default: 1).
SO_SOL_IP SO_IP_ADD_MEMBERSHIP SOIpMreq • • Joins to the IP host group to receive arriving multicast datagrams.
SO_SOL_IP SO_IP_DROP_MEMBERSHIP SOIpMreq • • Leave from the IP host group to stop delivering multicast datagrams.
SO_SOL_TCP SO_TCP_NODELAY BOOL •   Turn the Nagle's algorithm off.
SO_IPPROTO_IPV6 SO_IPV6_UNICAST_HOPS int • • Hop limit for IPv6 unicast datagrams.
SO_IPPROTO_IPV6 SO_IPV6_MULTICAST_LOOP unsigned int • • Loops back IPv6 multicast datagrams (default: enabled).
SO_IPPROTO_IPV6 SO_IPV6_MULTICAST_HOPS int • • Hop limit for IPv6 multicast datagrams.
SO_IPPROTO_IPV6 SO_IPV6_JOIN_GROUP SOIPv6Mreq • • Joins to the IPv6 host group to receive arriving multicast datagrams.
SO_IPPROTO_IPV6 SO_IPV6_LEAVE_GROUP SOIPv6Mreq • • Leave from the IPv6 host group to stop delivering multicast datagrams.

Note: To receive IPv4 multicast datagrams with SORecvFrom(), the receiving socket descriptor must be joined to the IPv4 host group using the SO_IP_ADD_MEMBERSHIP option and be bound to the UDP port of interest. The same goes for IPv6, except for using the SO_IPV6_JOIN_GROUP option instead of the SO_IP_ADD_MEMBERSHIP option.

Arguments

s The socket descriptor..
level The protocol level (one of SO_SO_*).
optname The option name to set (one of SO_* shown above).
optval The option value to set.
optlen The option length in bytes.

Return Values

zero Succeeded.
SO_EBADF Bad socket descriptor.
SO_EINVAL Invalid operation.
SO_ENETRESET Socket library is not initialized.
SO_ENOMEM Insufficient memory (for SO_SO_SNDBUF and SO_SO_RCVBUF).
SO_ENOPROTOOPT Non-supported option.

Note: Additional errors may be generated and returned in future library releases. All the negative return values must be treated as generic errors.

See Also

SOLinger, SOGetSockOpt()