Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

getsockopt (Windows Sockets)

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

This function retrieves a socket option.


int getsockopt(
  SOCKET s,
  int level,
  int optname,
  char FAR* optval,
  int FAR* optlen
);

s

[in] Descriptor identifying a socket.

level

[in] Level at which the option is defined; the supported levels include:

IPPROTO_IP

IPPROTO_IPV6

IPPROTO_TCP

IPPROTO_UDP

SOL_SOCKET

SOL_IRLMP

IPPROTO_RAW

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.

If no error occurs, this function returns zero. If an error occurs, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

The following table shows the possible error codes.

Error code Description

WSANOTINITIALISED

A successful WSAStartup call must occur before using this function.

WSAENETDOWN

The network subsystem has failed.

WSAEFAULT

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

WSAEINPROGRESS

A blocking Winsock call is in progress, or the service provider is still processing a callback function.

WSAEINVAL

The level parameter is unknown or invalid.

WSAENOPROTOOPT

The option is unknown or unsupported by the indicated protocol family.

WSAENOTSOCK

The descriptor is not a socket.

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 packet routing and out of band (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 linger structure. For most other options, it will be the size of an integer.

The application is responsible for allocating any memory space pointed to directly or indirectly by any of the parameters it specified.

If the option was never set with setsockopt (Windows Sockets), then getsockopt returns the default value for the option.

To view SOL_SOCKET options that are are supported for getsockopt, see SOL_SOCKET.

To view IPPROTO_TCP options that are are supported for getsockopt, see IPPROTO_TCP.

To view IPPROTO_IP options that are are supported for getsockopt, see IPPROTO_IP.

To view IPPROTO_IPv6 options that are are supported for getsockopt, see IPPROTO_IPV6.

To view IPPROTO_RAW options that are are supported for getsockopt, see Windows Mobile topic IPPROTO_RAW.

To view SOL_IRLMP options that are are supported for getsockopt, see SOL_IRLMP.

Aa916172.note(en-us,MSDN.10).gifNote:
Windows Embedded CE does not support Internetwork Packet Exchange (IPX).

The following list shows BSD options that are not supported in Windows Embedded CE for getsockopt

  • SO_RCVLOWAT
  • SO_RCVTIME
  • SO_SNDLOWAT
  • SO_SNDTIMEO
  • TCP_MAXSEG

Calling getsockopt with an unsupported option will result in an error code of WSAENOPROTOOPT being returned from WSAGetLastError.

  • The Af_irda.h header file must be explicitly included.
  • Windows NT® and Windows 2000 will return WSAENETDOWN to indicate the underlying transceiver driver failed to initialize with the IrDA protocol stack.
  • IrDA supports special socket options. For more information about these socket options, see SOL_IRLMP.
  • Many SO level socket options are not meaningful to IrDA; only SO_LINGER and SO_DONTLINGER are specifically supported.

For more inforamtion about IrDA support in Windows Embedded CE, see Infrared Communications.

Headerwinsock2.h
LibraryWs2.lib
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

Show:
© 2015 Microsoft