WSPSetSockOpt (Windows Embedded CE 6.0)

1/6/2010

This function sets a socket option.

Syntax

int WSPSetSockOpt(
  SOCKET s,
  int level,
  int optname,
  const char FAR* optval,
  int 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. The following table shows possible values for this parameter. To view SOL_SOCKET options that are are supported for WSPSetSockOpt, see SOL_SOCKET.
  • optname
    [in] Socket option for which the value is to be set.
  • optval
    [in] Pointer to the buffer in which the value for the requested option is supplied.
  • optlen
    [in] Size of the optval buffer.
  • lpErrno
    [out] Pointer to the error code.

Return Value

If no error occurs, WSPSetSockOpt 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

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

WSAEINPROGRESS

Function is invoked when a callback is in progress.

WSAEINPROGRESS

Blocking Windows Sockets call is in progress, or the service provider is still processing a callback function.

WSAEINVAL

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

WSAENETRESET

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

WSAENOPROTOOPT

Option is unknown or unsupported for the specified provider.

WSAENOTCONN

Connection has been reset when SO_KEEPALIVE is set.

WSAENOTSOCK

Descriptor is not a socket.

Remarks

This function sets the current value for a socket option associated with a socket of any type, in any state. Although options can exist at multiple protocol levels, they are always present at the uppermost socket level. Options affect socket operations, such as whether broadcast messages can be sent on the socket.

There are two types of socket options: Boolean options that enable or disable behavior, and options that require an integer value or structure. To enable a Boolean option, optval points to a nonzero integer. To disable the option, optval points to an integer equal to zero. The optlen parameter should be equal to sizeof (int) for Boolean options. For other options, optval points to the an integer or structure that contains the desired value for the option, and optlen is the length of the integer or structure.

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
WSPBind
WSPGetSockOpt
WSPIoctl
WSPSocket
WSPEventSelect

Concepts

Socket Options