#include <cafe.h>
#include <cafe/network.h>

int SOGetSockOpt(
                 int        fd, 
                 int        level, 
                 int        optname, 
                 void      *optval,
                 socklen_t *optlen


fd Descriptor of socket from which to retrieve option value.
level Protocol level at which the named option resides.
optname Option name. For more information, see SOSetSockOpt.
optval Destination for the option value. Cannot be NULL.
optlen Must be initialized with the size of optval; upon return, contains the number of bytes of the option value stored in optval. Cannot be NULL.

Return Values

0 upon success. Upon failure, -1 is returned and errno is set appropriately.


SO_ELIBNOTREADY Socket library is not initialized.
SO_ENOMEM Insufficient memory in the stack.
SO_EINVAL Specified argument is invalid.
SO_ENOTSOCK The argument fd does not refer to a socket.
SO_ENOPROTOOPT The option is unknown at the level indicated.
SO_EBUSY Socket resource manager busy processing requests.
SO_EABORTED Indicates the operation was aborted. For example, this error can be returned for calls blocked on a socket after the socket is closed by another thread.
SO_EUNKNOWN Unknown error.
SO_ERANGEINVALID Internal API error, invalid error code.
SO_EAPIERROR Internal API error.
SO_EOPNOTSUPP Non-supported operation.


Retrieves an option value for the specified socket. For a list of options, see SOSetSockOpt.

Do Not Call From

Callbacks Do not call this function from any callback function.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.

See Also


Revision History

2012/10/09 Updated Errors section.
2012/08/16 Cleanup pass.
2011/09/20 Mentioned the options, level, optval and optlen.
2011/07/11 Added Errors section.
2011/02/21 Initial version.