WSPSetSockOpt function

WSPSetSockOpt sets the value of an option for a socket.

Syntax

int WSPSetSockOpt(
  _In_        SOCKET   s,
  _In_        int      level,
  _In_        int      optname,
  _In_  const char FAR *optval,
  _In_        int      optlen,
  _Out_       LPINT    lpErrno
);

Parameters

  • s [in]
    Descriptor that identifies a socket.

  • level [in]
    Level at which the option is defined. If the TCP_NODELAY option is specified in the optname parameter, level should be IPPROTO_TCP. For all of the other options, use SOL_SOCKET level.

  • optname [in]
    Socket option for which the value is to be set. For a list of possible socket options, see the Remarks section.

  • optval [in]
    Pointer to a buffer that contains the value for the socket option that is specified in optname.

  • optlen [in]
    Size, in bytes, of the value at optval.

  • lpErrno [out]
    Pointer to a variable that receives the error code.

Return value

Returns zero if successful; otherwise, returns SOCKET_ERROR and, at lpErrno, one of the following error codes:

Return code Description
WSAENETDOWN

Network subsystem failed.

WSAEFAULT

The optval parameter is not in a valid part of the process address space or the optlen parameter is too small.

WSAEINVAL

The level parameter is not valid, or the information in the optval parameter is not valid.

WSAENETRESET

Connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.

WSAENOPROTOOPT

The option is unknown or unsupported for the SAN service provider.

WSAENOTCONN

The connection of the socket to the peer was reset.

WSAENOTSOCK

Descriptor is not a socket.

Note that a SAN service provider does not support the WSAEINPROGRESS error code for WSPSetSockOpt, because the switch never issues cancel blocking calls to a SAN service provider.

Remarks

The Windows Sockets switch calls a SAN service provider's WSPSetSockOpt function to assign a value to an option for a socket.

The following table shows the options that a SAN service provider supports and also describes data types for supported options.

Option Type Description

SO_DEBUG

BOOL

Debugging is either enabled or disabled. If set, SAN service providers should supply output debug information. However, they are not required to supply debug information.

SO_GROUP_PRIORITY

Integer

The relative priority for the socket in its group. Reserved for future use with socket groups.

The switch currently ignores the SO_GROUP_PRIORITY option. Group priority indicates the priority of the socket relative to other sockets within the group. Values are nonnegative integers, with zero corresponding to the highest priority. Priority values represent a hint to the SAN service provider about how to allocate potentially scarce resources. For example, whenever two or more sockets are both ready to transmit data, the highest priority socket (lowest value for SO_GROUP_PRIORITY) should be serviced first, with the remainder serviced in turn according to their relative priorities.

If the switch calls the SAN service provider's WSPSetSockOpt function with an unsupported option, or if the SAN service provider does not support group sockets, then the WSAENOPROTOOPT error code is returned.

Requirements

Target platform

Desktop

Version

Requires Windows Sockets version 2.0.

Header

Ws2spi.h (include Ws2spi.h)

See also

WSPGetSockOpt

WSPIoctl

WSPSocket

Send comments about this topic to Microsoft