Freigeben über


WSPSetSockOpt (Windows CE 5.0)

Send Feedback

This function sets a socket option.

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 Values

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

OS Versions: Windows CE .NET 4.0 and later.
Header: Ws2spi.h.
Link Library: Ws2.lib.

See Also

WSPBind | WSPGetSockOpt | WSPIoctl | WSPSocket | WSPEventSelect | Socket Options

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.