Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
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 optvalbuffer.
- lpErrno
-
[out] Pointer to the error code.
Return Value
If no error occurs, WSPSetSockOptreturns 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 optvalis not in a valid part of the process address space or optlenparameter 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 levelis not valid, or the information in optvalis 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_KEEPALIVEis 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, optvalpoints to a nonzero integer. To disable the option, optvalpoints to an integer equal to zero. The optlenparameter should be equal to sizeof (int) for Boolean options. For other options, optvalpoints to the an integer or structure that contains the desired value for the option, and optlenis the length of the integer or structure.
Calling WSPGetSockOptwith 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 |
Windows Mobile | Windows Mobile Version 5.0 and later |