Win Sock
Win Sock
* Socket Options
* Winsock IOCTLs
* Winsock Annexes
* Winsock Enumerations
* Winsock Functions
* Winsock Structures
* Winsock SPI
* Windows Sockets Error Codes
Socket Options
This section describes Winsock Socket Options for various editions of Windows
operating systems. Use the getsockopt and setsockopt functions for more getting
and setting socket options. To enumerate protocols and discover supported
properties for each installed protocol, use the WSAEnumProtocols function.
Some socket options require more explanation than these tables can convey; such
options contain links to additional pages.
IPPROTO_IP
Socket options applicable at the IPv4 level. For more information, see the
IPPROTO_IP Socket Options.
IPPROTO_IPV6
Socket options applicable at the IPv6 level. For more information, see the
IPPROTO_IPV6 Socket Options.
IPPROTO_RM
Socket options applicable at the TCP level. For more information, see the
IPPROTO_TCP Socket Options.
IPPROTO_UDP
Socket options applicable at the UDP level. For more information, see the
IPPROTO_UDP Socket Options.
NSPROTO_IPX
Socket options applicable at the IPX level. For more information, see the
NSPROTO_IPX Socket Options.
SOL_APPLETALK
Socket options applicable at the AppleTalk level. For more information, see
the SOL_APPLETALK Socket Options.
SOL_IRLMP
Socket options applicable at the InfraRed Link Management Protocol level. For
more information, see the SOL_IRLMP Socket Options.
SOL_SOCKET
Socket options applicable at the socket level. For more information, see the
SOL_SOCKET Socket Options.
__________________________________________________________________________________
________
Winsock IOCTLs
This section describes Winsock Socket IOCTLs for various editions of Windows
operating systems. Use the WSAIoctl or WSPIoctl function to issue a Winsock IOCTL
to control the mode of a socket, the transport protocol, or the communications
subsystem.
Some Winsock IOCTLs require more explanation than this table can convey; such
options contain links to additional pages.
Note The bits in dwIoControlCode parameter displayed in the table must be read
vertically from top to bottom by column. So the left-most bit is bit 31, the next
bit is bit 30, and the right-most bit is bit 0.
I is set if the input buffer is valid for the code, as with IOC_IN.
O is set if the output buffer is valid for the code, as with IOC_OUT. Control
codes using both input and output buffers set both I and O.
T is a 2-bit quantity that defines the type of the IOCTL. The following values are
defined:
0 The IOCTL is a standard Unix IOCTL code, as with FIONREAD and FIONBIO.
1 The IOCTL is a generic Windows Sockets 2 IOCTL code. New IOCTL codes defined for
Windows Sockets 2 will have T == 1.
3 The IOCTL applies only to a specific vendor's provider, as with IOC_VENDOR. This
type allows companies to be assigned a vendor number that appears in the
Vendor/Address family parameter. Then, the vendor can define new IOCTLs specific
to that vendor without having to register the IOCTL with a clearinghouse, thereby
providing vendor flexibility and privacy.
Vendor/Address family An 11-bit quantity that defines the vendor who owns the code
(if T == 3) or that contains the address family to which the code applies (if T ==
2). If this is a Unix IOCTL code (T == 0) then this parameter has the same value
as the code on Unix. If this is a generic Windows Sockets 2 IOCTL (T == 1) then
this parameter can be used as an extension of the code parameter to provide
additional code values.
Code The 16-bit quantity that contains the specific IOCTL code for the operation.
FIONBIO
Determine the amount of data that can be read atomically from socket s.
lpvOutBuffer points at an unsigned long in which WSAIoctl stores the result. If s
is stream oriented (for example, type SOCK_STREAM), FIONREAD returns the total
amount of data that can be read in a single receive operation; this is normally
the same as the total amount of data queued on the socket (since data stream is
byte-oriented, this is not guaranteed). If s is message oriented (for example,
type SOCK_DGRAM), FIONREAD returns the size of the first datagram (message) queued
on the socket.
SIOCATMARK
Determine whether or not all OOB data has been read. This applies only to
a socket of stream-style (for example, type SOCK_STREAM) that has been configured
for inline reception of any OOB data (SO_OOBINLINE). If no OOB data is waiting to
be read, the operation returns TRUE. Otherwise, it returns FALSE, and the next
receive operation performed on the socket will retrieve some or all of the data
preceding the mark; the application should use the SIOCATMARK operation to
determine whether any remains. If there is any normal data preceding the urgent
(out of band) data, it will be received in order. (Note that recv operations will
never mix OOB and normal data in the same call.) lpvOutBuffer points at a BOOL in
which WSAIoctl stores the result.
Copy Code
Note If the output buffer is not large enough to contain the address
list, SOCKET_ERROR is returned as the result of this IOCTL and WSAGetLastError
returns WSAEFAULT. The required size, in bytes, for the output buffer is returned
in the lpcbBytesReturned parameter in this case. Note the WSAEFAULT error code is
also returned if the lpvInBuffer, lpvOutBuffer, or lpcbBytesReturned parameter is
not completely contained in a valid part of the user address space.
SIO_ASSOCIATE_HANDLE (opcode setting: I, T==1)
Retrieves the base service provider handle for a given socket. The
returned value is a SOCKET.
A layered service provider would never intercept this IOCTL since the
return value must be the socket handle from the base service provider.
If the output buffer is not large enough for a socket handle (the
cbOutBuffer is less than the size of a SOCKET) or the lpvOutBuffer parameter is a
NULL pointer, SOCKET_ERROR is returned as the result of this IOCTL and
WSAGetLastError returns WSAEFAULT.
Retrieves the base service provider handle for a socket used by the
WSASendMsg function. The returned value is a SOCKET.
If the output buffer is not large enough for a socket handle (the
cbOutBuffer is less than the size of a SOCKET) or the lpvOutBuffer parameter is a
NULL pointer, SOCKET_ERROR is returned as the result of this IOCTL and
WSAGetLastError returns WSAEFAULT.
Retrieves the base service provider handle for a socket used by the select
function. The returned value is a SOCKET.
If the output buffer is not large enough for a socket handle (the
cbOutBuffer is less than the size of a SOCKET) or the lpvOutBuffer parameter is a
NULL pointer, SOCKET_ERROR is returned as the result of this IOCTL and
WSAGetLastError returns WSAEFAULT.
Retrieves the base service provider handle for a socket used by the
WSAPoll function. The lpOverlapped parameter must be a NULL pointer. The returned
value is a SOCKET.
If the output buffer is not large enough for a socket handle (the
cbOutBuffer is less than the size of a SOCKET), the lpvOutBuffer parameter is a
NULL pointer, or the lpOverlapped parameter is not a NULL pointer, SOCKET_ERROR is
returned as the result of this IOCTL and WSAGetLastError returns WSAEFAULT.
When issued, this IOCTL requests that the route to the remote address
specified as a sockaddr in the input buffer be discovered. If the address already
exists in the local cache, its entry is invalidated. In the case of Novell's IPX,
this call initiates an IPX GetLocalTarget (GLT), which queries the network for the
given remote address.
SIO_FLUSH (opcode setting: V, T==1)
This IOCTL fills the output buffer with a sockaddr structure containing a
suitable broadcast address for use with sendto/ WSASendTo. This IOCTL is not
supported for IPv6 sockets and returns the WSAENOPROTOOPT error code.
SIO_GET_EXTENSION_FUNCTION_POINTER (opcode setting: O, I, T==1)
The GUID values for extension functions supported by the Windows TCP/IP
service provider are defined in the Mswsock.h header file. The possible value for
these GUIDs are as follows:
Term Description
WSAID_ACCEPTEX
The AcceptEx extension function.
WSAID_CONNECTEX
WSAID_DISCONNECTEX
WSAID_GETACCEPTEXSOCKADDRS
WSAID_TRANSMITFILE
WSAID_TRANSMITPACKETS
WSAID_WSARECVMSG
WSAID_WSASENDMSG
Retrieve the QOS structure associated with the socket group to which this
socket belongs. The input buffer is optional. Some protocols (for example, RSVP)
allow the input buffer to be used to qualify a quality of service request. The QOS
structure will be copied into the output buffer. If this socket does not belong to
an appropriate socket group, the SendingFlowspec and ReceivingFlowspec members of
the returned QOS structure are set to NULL. The WSAENOPROTOOPT error code is
indicated for service providers that do not support quality of service.
SIO_GET_INTERFACE_LIST (opcode setting: O, T==0)
Reserved for future use with sockets. Retrieve the QOS structure
associated with the socket. The input buffer is optional. Some protocols (for
example, RSVP) allow the input buffer to be used to qualify a quality of service
request. The QOS structure will be copied into the output buffer. The output
buffer must be sized large enough to be able to contain the full QOS structure.
The WSAENOPROTOOPT error code is indicated for service providers that do not
support quality of service.
Notifies an application when the ideal send backlog (ISB) value changes
for the underlying connection.
The ISB value per connection is available from the TCP protocol
implementation in Windows Server 2008, Windows Vista SP1, and later versions of
the operating system. The SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL can be used by an
application to get notification when the ISB value changes dynamically for a
connection.
Retrieves the ideal send backlog (ISB) value for the underlying
connection.
The ISB value per connection is available from the TCP protocol
implementation in Windows Server 2008 and later. The SIO_IDEAL_SEND_BACKLOG_QUERY
IOCTL can be used by an application to query the ISB value for a connection.
Copy Code
Specifies the scope over which multicast transmissions will occur. Scope
is defined as the number of routed network segments to be covered. A scope of zero
would indicate that the multicast transmission would not be placed on the wire but
could be disseminated across sockets within the local host. A scope value of one
(the default) indicates that the transmission will be placed on the wire, but will
not cross any routers. Higher scope values determine the number of routers that
can be crossed. Note that this corresponds to the time-to-live (TTL) parameter in
IP multicasting. By default, scope is 1.
SIO_QUERY_RSS_SCALABILITY_INFO (opcode setting: O, T==3)
Copy Code
There are some firewall scenarios that may require the ability to inject
an inbound packet into the send path associated with an existing endpoint. There
needs to be a mechanism to discover the transport layer endpoint handle associated
with the destination endpoint. The application that created the endpoint owns
these transport layer endpoints. This IOCTL is used to provide socket handle to
transport layer endpoint handle mapping.
If the output buffer is not large enough for the endpoint handle (the
cbOutBuffer is less than the size of a UINT64) or the lpvOutBuffer parameter is a
NULL pointer, SOCKET_ERROR is returned as the result of this IOCTL and
WSAGetLastError returns WSAEINVAL.
Enables a socket to receive all IPv4 or IPv6 packets on the network. The
socket handle passed to the WSAIoctl function must be one of the following:
* An IPv4 socket that was created with the address family set to
AF_INET, the socket type set to SOCK_RAW, and the protocol set to IPPROTO_IP.
* An IPv6 socket that was created with the address family set to
AF_INET6, the socket type set to SOCK_RAW, and the protocol set to IPPROTO_IPV6.
The socket also must be bound to an explicit local IPv4 or IPv6 interface,
which means that you cannot bind to INADDR_ANY.
Once the socket is bound and the IOCTL completes successfully, calls to
the WSARecv or recv functions return IPv4 datagrams passing through the given IPv4
interface or return IPv6 datagrams passing through the given IPv6 interface. Note
that you must supply a sufficiently large buffer. Setting this IOCTL will only
capture IPv4 or IPv6 packets on a given interface. This IOCTL will not capture
other packets (ARP, IPX, and NetBEUI packets, for example) on the interface.
The possible values for the SIO_RCVALL IOCTL option are specified in the
RCVALL_VALUE enumeration defined in the Mstcpip.h header file. The possible values
for SIO_RCVALL are as follows:
Term Description
RCVALL_OFF
Disable this option so a socket does not receive all IPv4 or IPv6 packets
on the network.
RCVALL_ON
Enable this option so a socket receives all IPv4 or IPv6 packets on the
network. This option enables promiscuous mode on the network interface card (NIC),
if the NIC supports promiscuous mode. On a LAN segment with a network hub, a NIC
that supports promiscuous mode will capture all IPv4 or IPv6 traffic on the LAN,
including traffic between other computers on the same LAN segment. All of the
captured packets (IPv4 or IPv6, depending on the socket) will be delivered to the
raw socket.
This option will not capture other packets (ARP, IPX, and NetBEUI packets,
for example) on the interface.
Netmon uses the same mode for the network interface, but does not use this
option to capture traffic.
RCVALL_SOCKETLEVELONLY
This feature is not currently implemented, so setting this option does not
have any affect.
RCVALL_IPLEVEL
Enable this option so an IPv4 or IPv6 socket receives all packets at the
IP level on the network. This option does not enable promiscuous mode on the
network interface card. This option only affects packet processing at the IP
level. The NIC still receives only packets directed to its configured unicast and
multicast addresses. However, a socket with this option enabled will receive not
only packets directed to specific IP addresses, but will receive all the IPv4 or
IPv6 packets the NIC receives.
This option will not capture other packets (ARP, IPX, and NetBEUI packets,
for example) received on the interface.
Once the socket is bound and the IOCTL set, calls to the WSARecv or recv
functions return multicast IP datagrams passing through the given interface. Note
that you must supply a sufficiently large buffer. Setting this IOCTL requires
Administrator privilege on the local computer.
Once the socket is bound and the IOCTL set, calls to the WSARecv or recv
functions return multicast IP datagrams passing through the given interface. Note
that you must supply a sufficiently large buffer. Setting this IOCTL requires
Administrator privilege on the local computer.
If the output buffer is not large enough to contain the interface address,
SOCKET_ERROR is returned as the result of this IOCTL and WSAGetLastError returns
WSAEFAULT. The required size of the output buffer will be returned in
lpcbBytesReturned in this case. Note the WSAEFAULT error code is also returned if
the lpvInBuffer, lpvOutBuffer, or lpcbBytesReturned parameter is not totally
contained in a valid part of the user address space.
Requests how the networking stack should handle certain behaviors for
which the default way of handling the behavior may differ across Windows versions.
The argument structure for SIO_SET_COMPATIBILITY_MODE is specified in the
WSA_COMPATIBILITY_MODE structure defined in the Mswsockdef.h header file. This
structure is defined as follows:
Copy Code
Term Description
WsaBehaviorAll
This is equivalent to requesting all of the possible compatible behaviors
defined for WSA_COMPATIBILITY_BEHAVIOR_ID.
WsaBehaviorReceiveBuffering
WsaBehaviorAutoTuning
Reserved.
SIO_SET_QOS (opcode setting: I, T==1)
Associate the specified QOS structure with the socket. No output buffer is
required, the QOS structure will be obtained from the input buffer. The
WSAENOPROTOOPT error code is indicated for service providers that do not support
quality of service.
SIO_TRANSLATE_HANDLE (opcode setting: I, O, T==1)
__________________________________________________________________________________
__________
Winsock Annexes
Each protocol in this annex has conventions, behaviors, or special features that
do not lend themselves to generic implementation. This section documents details
that developers must consider when implementing or using the described protocols.
ATM is applicable to both LAN and WAN environments. An ATM network simultaneously
transports a wide variety of network traffic � voice, data, image, and video. It
provides users with a guaranteed quality of service on a per-virtual channel (VC)
basis.
Element Description
Protocol name(s) ATMPROTO_AAL5, ATMPROTO_AALUSER
Description ATM AAL5 provides a transport service that is connection
oriented, message-boundary preserved, and QOS guaranteed. ATMPROTO_AALUSER is a
user-defined AAL.
Address family AF_ATM
Header file Ws2atm.h
Element Description
Protocol name(s) IPX, SPX
Description Provides transport services over the IPX networking layer: IPX
for unreliable datagrams, SPX for reliable, connection-oriented message streams.
Address family AF_IPX
Header file Wsipx.h
This section discusses how to use Winsock with the IPX family of protocols,
enabling traditional IPX applications to be ported to Winsock. IPX networks
operate in a fundamentally different manner than IP networks, so such differences
must be considered when using IPX/SPX.
Element Description
Protocol name(s) TCP, UDP
Description Provides transport services over the IP networking layer: UDP for
unreliable datagrams, TCP for reliable, connection-oriented byte streams.
Address family AF_INET, AF_INET6
Header file Ws2tcpip.h
Two basic types of transport services are offered: unreliable datagrams (UDP), and
reliable connection oriented�byte streams (TCP). In addition, a raw socket is
optionally supported. Raw sockets allow an application to communicate through
protocols other than TCP and UDP such as ICMP. Raw sockets are supported on the
AF_INET and AF_INET6 address families with some limitations.
This section covers extensions to Winsock that are specific to TCP/IP protocols.
It also describes aspects of base Winsock functions that require special
consideration or that may exhibit unique behavior when using TCP/IP.
__________________________________________________________________________________
_________________
Winsock Enumerations
The following list provides concise descriptions of each Winsock enumeration. For
additional information on any enumeration, click the enumeration name.
Enumeration Description
eWINDOW_ADVANCE_METHOD Specifies the window advance mode used for Reliable
Multicast.
GUARANTEE No longer used.
MULTICAST_MODE_TYPE Specifies the filter mode for multicast group addresses.
NAPI_PROVIDER_LEVEL Specifies the provider authority level of a NS_EMAIL
namespace provider for a given domain.
NAPI_PROVIDER_TYPE Specifies the type of hosting expected for a namespace
provider.
SOCKET_SECURITY_PROTOCOL Indicates the type of security protocol to be used on
a socket.
SOCKET_USAGE_TYPE Used to specified the usage type for the socket.
WSAECOMPARATOR Used for version-comparison semantics.
WSC_PROVIDER_INFO_TYPE Specifies the information class of a layered service
protocol (LSP).
__________________________________________________________________________________
_________________
Winsock Functions
The following list provides concise descriptions of each Winsock function. For
additional information on any function, click the function name.
Function Description
accept Permits an incoming connection attempt on a socket.
AcceptEx Accepts a new connection, returns the local and remote address, and
receives the first block of data sent by the client application.
bind Associates a local address with a socket.
closesocket Closes an existing socket.
connect Establishes a connection to a specified socket.
ConnectEx Establishes a connection to a specified socket, and optionally sends
data once the connection is established. Only supported on connection-oriented
sockets.
DisconnectEx Closes a connection on a socket, and allows the socket handle to
be reused.
EnumProtocols Retrieves information about a specified set of network protocols
that are active on a local host.
freeaddrinfo Frees address information that the getaddrinfo function
dynamically allocates in addrinfo structures.
FreeAddrInfoEx Frees address information that the GetAddrInfoEx function
dynamically allocates in addrinfoex structures.
FreeAddrInfoW Frees address information that the GetAddrInfoW function
dynamically allocates in addrinfoW structures.
gai_strerror Assists in printing error messages based on the EAI_* errors
returned by the getaddrinfo function.
GetAcceptExSockaddrs Parses the data obtained from a call to the AcceptEx
function.
GetAddressByName Queries a namespace, or a set of default namespaces, to retrieve
network address information for a specified network service. This process is known
as service name resolution. A network service can also use the function to obtain
local address information that it can use with the bind function.
getaddrinfo Provides protocol-independent translation from an ANSI host name
to an address.
GetAddrInfoW Provides protocol-independent translation from a Unicode host
name to an address.
GetAddrInfoEx Provides protocol-independent name resolution with additional
parameters to qualify which name space providers should handle the request.
gethostbyaddr Retrieves the host information corresponding to a network
address.
gethostbyname Retrieves host information corresponding to a host name from a
host database. Deprecated: use getaddrinfo instead.
gethostname Retrieves the standard host name for the local computer.
GetNameByType Retrieves the name of a network service for the specified service
type.
getnameinfo Provides name resolution from an IPv4 or IPv6 address to an ANSI
host name and from a port number to the ANSI service name.
GetNameInfoW Provides name resolution from an IPv4 or IPv6 address to a
Unicode host name and from a port number to the Unicode service name.
getpeername Retrieves the address of the peer to which a socket is connected.
getprotobyname Retrieves the protocol information corresponding to a protocol
name.
getprotobynumber Retrieves protocol information corresponding to a protocol
number.
getservbyname Retrieves service information corresponding to a service name and
protocol.
getservbyport Retrieves service information corresponding to a port and
protocol.
GetService Retrieves information about a network service in the context of a set
of default namespaces or a specified namespace.
getsockname Retrieves the local name for a socket.
getsockopt Retrieves a socket option.
GetTypeByName Retrieves a service type GUID for a network service specified by
name.
htonl Converts a u_long from host to TCP/IP network byte order (which is big-
endian).
htons Converts a u_short from host to TCP/IP network byte order (which is
big-endian).
inet_addr Converts a string containing an (Ipv4) Internet Protocol dotted address
into a proper address for the in_addr structure.
inet_ntoa Converts an (IPv4) Internet network address into a string in Internet
standard dotted format.
InetNtop converts an IPv4 or IPv6 Internet network address into a string in
Internet standard format. The ANSI version of this function is inet_ntop.
InetPton Converts an IPv4 or IPv6 Internet network address in its standard text
presentation form into its numeric binary form. The ANSI version of this function
is inet_pton.
ioctlsocket Controls the I/O mode of a socket.
listen Places a socket a state where it is listening for an incoming
connection.
ntohl Converts a u_long from TCP/IP network order to host byte order (which
is little-endian on Intel processors).
ntohs Converts a u_short from TCP/IP network byte order to host byte order
(which is little-endian on Intel processors).
recv Receives data from a connected or bound socket.
recvfrom Receives a datagram and stores the source address.
select Determines the status of one or more sockets, waiting if necessary, to
perform synchronous I/O.
send Sends data on a connected socket.
sendto Sends data to a specific destination.
SetAddrInfoEx Registers a host and service name along with associated addresses
with a specific namespace provider.
SetService Registers or removes from the registry a network service within one or
more namespaces. Can also add or remove a network service type within one or more
namespaces.
setsockopt Sets a socket option.
shutdown Disables sends or receives on a socket.
socket Creates a socket that is bound to a specific service provider.
TransmitFile Transmits file data over a connected socket handle.
TransmitPackets Transmits in-memory data or file data over a connected socket.
WSAAccept Conditionally accepts a connection based on the return value of a
condition function, provides quality of service flow specifications, and allows
the transfer of connection data.
WSAAddressToString Converts all components of a sockaddr structure into a
human-readable string representation of the address.
WSAAsyncGetHostByAddr Asynchronously retrieves host information that corresponds
to an address.
WSAAsyncGetHostByName Asynchronously retrieves host information that corresponds
to a host name.
WSAAsyncGetProtoByName Asynchronously retrieves protocol information that
corresponds to a protocol name.
WSAAsyncGetProtoByNumber Asynchronously retrieves protocol information that
corresponds to a protocol number.
WSAAsyncGetServByName Asynchronously retrieves service information that
corresponds to a service name and port.
WSAAsyncGetServByPort Asynchronously retrieves service information that
corresponds to a port and protocol.
WSAAsyncSelect Requests Windows message-based notification of network events for
a socket.
WSACancelAsyncRequest Cancels an incomplete asynchronous operation.
WSACleanup Terminates use of the Ws2_32.DLL.
WSACloseEvent Closes an open event object handle.
WSAConnect Establishes a connection to another socket application, exchanges
connect data, and specifies needed quality of service based on the specified
FLOWSPEC structure.
WSAConnectByList Establishes a connection to one out of a collection of possible
endpoints represented by a set of destination addresses (host names and ports).
WSAConnectByName Establishes a connection to another socket application on a
specified host and port
WSACreateEvent Creates a new event object.
WSADeleteSocketPeerTargetName Removes the association between a peer target
name and an IP address for a socket.
WSADuplicateSocket Returns a structure that can be used to create a new socket
descriptor for a shared socket.
WSAEnumNameSpaceProviders Retrieves information about available namespaces.
WSAEnumNameSpaceProvidersEx Retrieves information about available namespaces.
WSAEnumNetworkEvents Discovers occurrences of network events for the indicated
socket, clear internal network event records, and reset event objects (optional).
WSAEnumProtocols Retrieves information about available transport protocols.
WSAEventSelect Specifies an event object to be associated with the specified set
of FD_XXX network events.
__WSAFDIsSet Specifies whether a socket is included in a set of socket
descriptors.
WSAGetLastError Returns the error status for the last operation that failed.
WSAGetOverlappedResult Retrieves the results of an overlapped operation on the
specified socket.
WSAGetQOSByName Initializes a QOS structure based on a named template, or it
supplies a buffer to retrieve an enumeration of the available template names.
WSAGetServiceClassInfo Retrieves the class information (schema) pertaining to a
specified service class from a specified namespace provider.
WSAGetServiceClassNameByClassId Retrieves the name of the service associated
with the specified type.
WSAHtonl Converts a u_long from host byte order to network byte order.
WSAHtons Converts a u_short from host byte order to network byte order.
WSAImpersonateSocketPeer Used to impersonate the security principal
corresponding to a socket peer in order to perform application-level
authorization.
WSAInstallServiceClass Registers a service class schema within a namespace.
WSAIoctl Controls the mode of a socket.
WSAJoinLeaf Joins a leaf node into a multipoint session, exchanges connect
data, and specifies needed quality of service based on the specified structures.
WSALookupServiceBegin Initiates a client query that is constrained by the
information contained within a WSAQUERYSET structure.
WSALookupServiceEnd Frees the handle used by previous calls to
WSALookupServiceBegin and WSALookupServiceNext.
WSALookupServiceNext Retrieve the requested service information.
WSANSPIoctl Developers to make I/O control calls to a registered namespace.
WSANtohl Converts a u_long from network byte order to host byte order.
WSANtohs Converts a u_short from network byte order to host byte order.
WSAPoll Determines status of one or more sockets.
WSAProviderConfigChange Notifies the application when the provider
configuration is changed.
WSAQuerySocketSecurity Queries information about the security applied to a
connection on a socket.
WSARecv Receives data from a connected socket.
WSARecvDisconnect Terminates reception on a socket, and retrieves the
disconnect data if the socket is connection oriented.
WSARecvEx Receives data from a connected socket.
WSARecvFrom Receives a datagram and stores the source address.
WSARecvMsg Receives data and optional control information from connected and
unconnected sockets.
WSARemoveServiceClass Permanently removes the service class schema from the
registry.
WSAResetEvent Resets the state of the specified event object to nonsignaled.
WSARevertImpersonation Terminates the impersonation of a socket peer.
WSASend Sends data on a connected socket.
WSASendDisconnect Initiates termination of the connection for the socket and
sends disconnect data.
WSASendMsg Sends data and optional control information from connected and
unconnected sockets.
WSASendTo Sends data to a specific destination, using overlapped I/O where
applicable.
WSASetEvent Sets the state of the specified event object to signaled.
WSASetLastError Sets the error code.
WSASetService Registers or removes from the registry a service instance within
one or more namespaces.
WSASetSocketPeerTargetName Used to specify the peer target name (SPN) that
corresponds to a peer IP address. This target name is meant to be specified by
client applications to securely identify the peer that should be authenticated.
WSASetSocketSecurity Enables and applies security for a socket.
WSASocket Creates a socket that is bound to a specific transport-service
provider.
WSAStartup Initiates use of WS2_32.DLL by a process.
WSAStringToAddress Converts a numeric string to a sockaddr structure.
WSAWaitForMultipleEvents Returns either when one or all of the specified event
objects are in the signaled state, or when the time-out interval expires.
__________________________________________________________________________________
_________
Winsock Structures
The following list provides concise descriptions of each Winsock structure. For
additional information on any structure, click the structure name.
Structure Description
addrinfo Used by the getaddrinfo function to hold host address information.
addrinfoW Used by the GetAddrInfoW function to hold host address information.
addrinfoex Used by the GetAddrInfoEx function to hold host address information.
AFPROTOCOLS Supplies a list of protocols to which application programmers can
constrain queries. Used for query purposes only.
BLOB Contains information about a block of data. Derived from Binary Large
Object.
CSADDR_INFO Contains Winsock address information for a network service or
namespace provider.
fd_set Used by various Winsock functions and service providers, such as
select, to place sockets into a "set" for various purposes, such as testing a
given socket for readability.
GROUP_FILTER Provides multicast filtering parameters for multicast IPv6 or
IPv4 addresses.
GROUP_REQ Provides multicast group information for IPv6 or IPv4 addresses.
GROUP_SOURCE_REQ Provides multicast group information for IPv6 or IPv4 addresses
that includes the source IP address.
hostent Stores information about a given host, such as host name, IP address,
and so forth.
in_addr Represents an IPv4 Internet address.
in_pktinfo Stores received packet address information, and is used by Windows to
return information about received packets.
in6_addr Represents an IPv6 Internet address.
in6_pktinfo Stores received IPv6 packet address information, and is used by
Windows to return information about received packets.
ip_mreq Provides multicast group information for IPv4 addresses.
ip_mreq_source Provides multicast group and source information for IPv4
addresses.
ip_msfilter Provides multicast filtering parameters for IPv4 addresses.
ipv6_mreq Provides multicast group information for IPv6 addresses.
linger Maintains information about a specific socket that specifies how that
socket should behave when data is queued to be sent and the closesocket function
is called on the socket.
NAPI_DOMAIN_DESCRIPTION_BLOB Describes a domain handled by a namespace provider
for the NS_EMAIL namespace.
NAPI_PROVIDER_INSTALLATION_BLOB Contains the information required to install a
namespace provider for the NS_EMAIL namespace.
NS_SERVICE_INFO Contains information about a network service or a network service
type in the context of a specified namespace, or a set of default namespaces.
PROTOCOL_INFO Contains information about a protocol.
protoent Contains the name and protocol numbers that correspond to a given
protocol name.
RM_FEC_INFO Specifies settings for using forward error correction (FEC) with
Reliable Multicast.
RM_RECEIVER_STATS Provides statistical information for a Reliable Multicast
receiver session.
RM_SEND_WINDOW Specifies the Reliable Multicast send window.
RM_SENDER_STATS Provides statistical information for a Reliable Multicast sender
session.
servent Stores or returns the name and service number for a given service name.
SERVICE_ADDRESS Contains address information for a service.
SERVICE_ADDRESSES Contains an array of SERVICE_ADDRESS data structures.
SERVICE_INFO Contains information about a network service or a network service
type.
SERVICE_TYPE_INFO_ABS Contains information about a network service type.
SERVICE_TYPE_VALUE_ABS Contains information about a network-service type value.
The information may be specific to a namespace.
sockaddr Contains socket address information. The sockaddr structure varies
depending on the protocol selected. Limited to IPv4; use SOCKADDR_STORAGE instead.
SOCKADDR_IRDA Used with IrDA socket operations, defined by address family
AF_IRDA.
SOCKADDR_STORAGE Stores socket address information, and is sufficiently large to
store IPv4 or IPv6 address information, promoting protocol-family and protocol-
version independence. Use this structure in place of the sockaddr structure.
SOCKET_ADDRESS Stores protocol-specific address information.
SOCKET_ADDRESS_LIST Stores an array of SOCKET_ADDRESS structures that contain
protocol-specific address information.
SOCKET_PEER_TARGET_NAME Contains the IP address and name for a peer target
and the type of security protocol to be used on a socket.
SOCKET_SECURITY_QUERY_INFO Contains security information returned by the
WSAQuerySocketSecurity function.
SOCKET_SECURITY_QUERY_TEMPLATE Contains the security template used by the
WSAQuerySocketSecurity function.
SOCKET_SECURITY_SETTINGS Specifies generic security requirements for a socket.
SOCKET_SECURITY_SETTINGS_IPSEC Specifies various security requirements and
settings that are specific to IPsec.
timeval Used to specify time values. Associated with the Berkeley Software
Distribution (BSD) file Time.h.
TRANSMIT_FILE_BUFFERS Specifies data to be transmitted before and after file data
during a TransmitFile transfer operation.
TRANSMIT_PACKETS_ELEMENT Specifies a single data element to be transmitted by
the TransmitPackets function.
WSABUF Enables the creation or manipulation of a data buffer.
WSACOMPLETION Specifies completion notification settings for I/O control calls
made to a registered namespace.
WSADATA Contains information about the Windows Sockets implementation.
WSAMSG Stores address and optional control information about connected and
unconnected sockets. Used with the WSARecvMsg function.
WSANAMESPACE_INFO Contains registration information for a namespace provider.
WSANAMESPACE_INFOEX Contains enhanced registration information for a namespace
provider.
WSANETWORKEVENTS Stores a socket's internal information about network events.
WSANSCLASSINFO Provides individual parameter information for a specific Winsock
namespace.
WSAOVERLAPPED Provides a communication medium between the initiation of an
overlapped I/O operation and its subsequent completion.
WSAPOLLFD Stores socket information used by the WSAPoll function.
WSAPROTOCOL_INFO Stores or retrieves complete information for a given protocol.
WSAPROTOCOL_INFOW Store or retrieves complete information for a given
protocol. The protocol name is represented as an array of Unicode characters.
WSAPROTOCOLCHAIN Contains a counted list of Catalog Entry identifiers that
comprise a protocol chain.
WSAQUERYSET Provides relevant information about a given service.
WSAQUERYSET2 Provides relevant information about a given service.
WSASERVICECLASSINFO Contains information about a specified service class.
WSAVERSION Provides version comparison in Winsock.
_________________________________________________________________________________
Winsock SPI
The Winsock SPI uses the following function prefix naming convention.
Prefix Meaning Description
WSP Windows Sockets Service Provider Transport service provider entry points
WPU Windows Sockets Provider Upcall Ws2_32.dll entry points for service
providers
WSC Windows Sockets Configuration WS2_32.dll entry points for installation
applets
NSP Namespace Provider Namespace provider entry points
_________________________________________________________________________________
Most Windows Sockets 2 functions do not return the specific cause of an error when
the function returns. For information, see the Handling Winsock Errors topic.
The following list describes the possible error codes returned by the
WSAGetLastError function. Errors are listed in numerical order with the error
macro name. Some error codes defined in Winsock2.h are not returned from any
function.
Return code/value Description
Another possible reason for the WSAEACCES error is that when the bind function
is called (on Windows NT 4 SP4 or later), another application, service, or kernel
mode driver is bound to the same address with exclusive access. Such exclusive
access is a new feature of Windows NT 4 SP4 and later, and is implemented by using
the SO_EXCLUSIVEADDRUSE option.
WSAESOCKTNOSUPPORT
10044
The support for the specified socket type does not exist in this address
family. For example, the optional type SOCK_RAW might be selected in a socket
call, and the implementation does not support SOCK_RAW sockets at all.
WSAEOPNOTSUPP
10045
The attempted operation is not supported for the type of object referenced.
Usually this occurs when a socket descriptor to a socket that cannot support this
operation is trying to accept a connection on a datagram socket.
WSAEPFNOSUPPORT
10046
The protocol family has not been configured into the system or no
implementation for it exists. This message has a slightly different meaning from
WSAEAFNOSUPPORT. However, it is interchangeable in most cases, and all Windows
Sockets functions that return one of these messages also specify WSAEAFNOSUPPORT.
WSAEAFNOSUPPORT
10047
An address incompatible with the requested protocol was used. All sockets are
created with an associated address family (that is, AF_INET for Internet
Protocols) and a generic protocol type (that is, SOCK_STREAM). This error is
returned if an incorrect protocol is explicitly requested in the socket call, or
if an address of the wrong family is used for a socket, for example, in sendto.
WSAEADDRINUSE
10048
WSAEADDRNOTAVAIL
10049
The requested address is not valid in its context. This normally results from
an attempt to bind to an address that is not valid for the local computer. This
can also result from connect, sendto, WSAConnect, WSAJoinLeaf, or WSASendTo when
the remote address or port is not valid for a remote computer (for example,
address or port 0).
WSAENETDOWN
10050
Network is down.
WSAENETUNREACH
10051
Network is unreachable.
WSAENETRESET
10052
The connection has been broken due to keep-alive activity detecting a failure
while the operation was in progress. It can also be returned by setsockopt if an
attempt is made to set SO_KEEPALIVE on a connection that has already failed.
WSAECONNABORTED
10053
WSAECONNRESET
10054
An existing connection was forcibly closed by the remote host. This normally
results if the peer application on the remote host is suddenly stopped, the host
is rebooted, the host or remote network interface is disabled, or the remote host
uses a hard close (see setsockopt for more information on the SO_LINGER option on
the remote socket). This error may also result if a connection was broken due to
keep-alive activity detecting a failure while one or more operations are in
progress. Operations that were in progress fail with WSAENETRESET. Subsequent
operations fail with WSAECONNRESET.
WSAENOBUFS
10055
WSAEISCONN
10056
WSAENOTCONN
10057
A request to send or receive data was disallowed because the socket is not
connected and (when sending on a datagram socket using sendto) no address was
supplied. Any other type of operation might also return this error�for example,
setsockopt setting SO_KEEPALIVE if the connection has been reset.
WSAESHUTDOWN
10058
A request to send or receive data was disallowed because the socket had
already been shut down in that direction with a previous shutdown call. By calling
shutdown a partial close of a socket is requested, which is a signal that sending
or receiving, or both have been discontinued.
WSAETOOMANYREFS
10059
WSAETIMEDOUT
10060
A connection attempt failed because the connected party did not properly
respond after a period of time, or the established connection failed because the
connected host has failed to respond.
WSAECONNREFUSED
10061
Connection refused.
No connection could be made because the target computer actively refused it.
This usually results from trying to connect to a service that is inactive on the
foreign host�that is, one with no server application running.
WSAELOOP
10062
WSAENAMETOOLONG
10063
WSAEHOSTDOWN
10064
Host is down.
WSAEHOSTUNREACH
10065
No route to host.
WSAENOTEMPTY
10066
WSAEPROCLIM
10067
WSAEUSERS
10068
WSAEDQUOT
10069
* That the appropriate Windows Sockets DLL file is in the current path.
* That they are not trying to use more than one Windows Sockets implementation
simultaneously. If there is more than one Winsock DLL on your system, be sure the
first one in the path is appropriate for the network subsystem currently loaded.
* The Windows Sockets implementation documentation to be sure all necessary
components are currently installed and configured correctly.
The current Windows Sockets implementation does not support the Windows
Sockets specification version requested by the application. Check that no old
Windows Sockets DLL files are being accessed.
Either the application has not called WSAStartup or WSAStartup failed. The
application may be accessing a socket that the current active task does not own
(that is, trying to share a socket between tasks), or WSACleanup has been called
too many times.
Returned by WSARecv and WSARecvFrom to indicate that the remote party has
initiated a graceful shutdown sequence.
A call to the WSALookupServiceEnd function was made while this call was still
processing. The call has been canceled.
The requested service provider could not be loaded or initialized. This error
is returned if either a service provider's DLL could not be loaded (LoadLibrary
failed) or the provider's WSPStartup or NSPStartup function failed.
A system call that should never fail has failed. This is a generic error code,
returned under various conditions.
Returned when a system call that should never fail does fail. For example, if
a call to WaitForMultipleEvents fails or one of the registry functions fails
trying to manipulate the protocol/namespace catalogs.
Returned when a provider does not return SUCCESS and does not provide an
extended error code. Can indicate a service provider implementation error.
No such service is known. The service cannot be found in the specified name
space.
WSA_E_CANCELLED
10111
A call to the WSALookupServiceEnd function was made while this call was still
processing. The call has been canceled.
WSAEREFUSED
10112
WSAHOST_NOT_FOUND
11001
No such host is known. The name is not an official host name or alias, or it
cannot be found in the database(s) being queried. This error may also be returned
for protocol and service queries, and means that the specified name could not be
found in the relevant database.
WSATRY_AGAIN
11002
This is usually a temporary error during host name resolution and means that
the local server did not receive a response from an authoritative server. A retry
at some time later may be successful.
WSANO_RECOVERY
11003
This is a nonrecoverable error.
WSANO_DATA
11004
The requested name is valid and was found in the database, but it does not
have the correct associated data being resolved for. The usual example for this is
a host name-to-address translation attempt (using gethostbyname or
WSAAsyncGetHostByName) which uses the DNS (Domain Name Server). An MX record is
returned but no A record�indicating the host itself exists, but is not directly
reachable.
WSA_QOS_RECEIVERS
11005
QOS receivers.
WSA_QOS_SENDERS
11006
QOS senders.
WSA_QOS_NO_SENDERS
11007
No QOS senders.
WSA_QOS_NO_RECEIVERS
11008
QOS no receivers.
WSA_QOS_REQUEST_CONFIRMED
11009
WSA_QOS_ADMISSION_FAILURE
11010
WSA_QOS_POLICY_FAILURE
11011
The QOS request was rejected because the policy system couldn't allocate the
requested resource within the existing policy.
A problem was encountered with some part of the filterspec or the provider-
specific buffer in general.
An error with the underlying traffic control (TC) API as the generic QOS
request was converted for local enforcement by the TC API. This could be due to an
out of memory error or to an internal QOS provider error.
An invalid QOS flow descriptor was found in the flow descriptor list.