Share via


WSPGetSockOpt (Windows Embedded CE 6.0)

1/6/2010

This function retrieves a socket option.

Syntax

int WSPGetSockOpt(
  SOCKET s,
  int level,
  int optname,
  char FAR* optval,
  LPINT optlen,
  LPINT lpErrno 
);

Parameters

  • s
    [in] Descriptor identifying a socket.
  • level
    [in] Level at which the option is defined; the supported levels include SOL_SOCKET. To view SOL_SOCKET options that are are supported for WSPGetSockOpt, see SOL_SOCKET.
  • optname
    [in] Socket option for which the value is to be retrieved.
  • optval
    [out] Pointer to the buffer in which the value for the requested option is to be returned.
  • optlen
    [in, out] Pointer to the size of the optval buffer.
  • lpErrno
    [out] A pointer to the error code.

Return Value

If no error occurs, this function returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code is available in lpErrno.

The following table shows the possible error codes.

Error value Description

WSAENETDOWN

Network subsystem has failed.

WSAEFAULT

One of the optval or the optlen parameters is not a valid part of the user address space, or the optlen parameter is too small.

WSAEINVAL

The level is unknown or invalid.

WSAEINPROGRESS

Function is invoked when a callback is in progress.

WSAENOPROTOOPT

Option is unknown or unsupported by the indicated protocol family.

WSAENOTSOCK

Descriptor is not a socket.

Remarks

This function retrieves the current value for a socket option associated with a socket of any type, in any state, and stores the result in optval. Options can exist at multiple protocol levels, but they are always present at the uppermost socket level. Options affect socket operations, such as the routing of packets and OOB data transfer.

The value associated with the selected option is returned in the buffer optval. The integer pointed to by optlen should originally contain the size of this buffer; on return, it will be set to the size of the value returned. For SO_LINGER, this will be the size of a structure linger; for most other options it will be the size of an integer.

The Windows Sockets SPI client is responsible for allocating any memory space pointed to directly or indirectly by any of the parameters it specifies.

If the option was never set with WSPSetSockOpt, then WSPGetSockOpt returns the default value for the option.

Calling WSPGetSockOpt with an unsupported option will result in an error code of WSAENOPROTOOPT being returned in lpErrno.

Requirements

Header ws2spi.h
Library Ws2.lib
Windows Embedded CE Windows CE .NET 4.0 and later

See Also

Reference

Winsock SPI Functions
WSPSetSockOpt
WSPSocket

Concepts

Socket Options