Document
Document
Winsock2.h
Overview
__WSAFDIsSet function
accept function
AFPROTOCOLS structure
bind function
BLOB structure
closesocket function
connect function
fd_set structure
FD_SET macro
gethostbyaddr function
gethostbyname function
gethostname function
GetHostNameW function
getpeername function
getprotobyname function
getprotobynumber function
getservbyname function
getservbyport function
getsockname function
getsockopt function
HOSTENT structure
htond function
htonf function
htonl function
htonll function
htons function
in_addr structure
inet_addr function
inet_ntoa function
ioctlsocket function
LINGER structure
listen function
LPWSAOVERLAPPED_COMPLETION_ROUTINE callback function
ntohd function
ntohf function
ntohl function
ntohll function
ntohs function
ProcessSocketNotifications function
PROTOENT structure
QOS structure
recv function
recvfrom function
select function
send function
sendto function
SERVENT structure
setsockopt function
shutdown function
SOCK_NOTIFY_REGISTRATION structure
socket function
SocketNotificationRetrieveEvents function
TIMEVAL structure
WSAAccept function
WSAAddressToStringA function
WSAAddressToStringW function
WSAAsyncGetHostByAddr function
WSAAsyncGetHostByName function
WSAAsyncGetProtoByName function
WSAAsyncGetProtoByNumber function
WSAAsyncGetServByName function
WSAAsyncGetServByPort function
WSAAsyncSelect function
WSACancelAsyncRequest function
WSACancelBlockingCall function
WSACleanup function
WSACloseEvent function
WSACOMPLETION structure
WSAConnect function
WSAConnectByList function
WSAConnectByNameA function
WSAConnectByNameW function
WSACreateEvent function
WSADATA structure
WSADuplicateSocketA function
WSADuplicateSocketW function
WSAECOMPARATOR enumeration
WSAEnumNameSpaceProvidersA function
WSAEnumNameSpaceProvidersExA function
WSAEnumNameSpaceProvidersExW function
WSAEnumNameSpaceProvidersW function
WSAEnumNetworkEvents function
WSAEnumProtocolsA function
WSAEnumProtocolsW function
WSAEventSelect function
WSAGetLastError function
WSAGetOverlappedResult function
WSAGetQOSByName function
WSAGetServiceClassInfoA function
WSAGetServiceClassInfoW function
WSAGetServiceClassNameByClassIdA function
WSAGetServiceClassNameByClassIdW function
WSAHtonl function
WSAHtons function
WSAInstallServiceClassA function
WSAInstallServiceClassW function
WSAIoctl function
WSAIsBlocking function
WSAJoinLeaf function
WSALookupServiceBeginA function
WSALookupServiceBeginW function
WSALookupServiceEnd function
WSALookupServiceNextA function
WSALookupServiceNextW function
WSANAMESPACE_INFOA structure
WSANAMESPACE_INFOEXA structure
WSANAMESPACE_INFOEXW structure
WSANAMESPACE_INFOW structure
WSANETWORKEVENTS structure
WSANSCLASSINFOA structure
WSANSCLASSINFOW structure
WSANSPIoctl function
WSANtohl function
WSANtohs function
WSAOVERLAPPED structure
WSAPoll function
WSAPOLLFD structure
WSAPROTOCOL_INFOA structure
WSAPROTOCOL_INFOW structure
WSAPROTOCOLCHAIN structure
WSAProviderConfigChange function
WSAQUERYSET2A structure
WSAQUERYSET2W structure
WSAQUERYSETA structure
WSAQUERYSETW structure
WSARecv function
WSARecvDisconnect function
WSARecvFrom function
WSARemoveServiceClass function
WSAResetEvent function
WSASend function
WSASendDisconnect function
WSASendMsg function
WSASendTo function
WSASERVICECLASSINFOA structure
WSASERVICECLASSINFOW structure
WSASetBlockingHook function
WSASetEvent function
WSASetLastError function
WSASetServiceA function
WSASetServiceW function
WSASocketA function
WSASocketW function
WSAStartup function
WSAStringToAddressA function
WSAStringToAddressW function
WSAUnhookBlockingHook function
WSAVERSION structure
WSAWaitForMultipleEvents function
winsock2.h header
6/2/2021 • 12 minutes to read • Edit Online
This header is used by Quality of Service (QOS). For more information, see:
Quality of Service (QOS)
winsock2.h contains the following programming interfaces:
Functions
__WSAFDIsSet
The __WSAFDIsSet function specifies whether a socket is included in a set of socket descriptors.
accept
bind
closesocket
connect
FD_SET
Fd_set structure is used by Windows Sockets (Winsock) functions and service providers to place sockets into a set.
gethostbyaddr
gethostbyname
The gethostbyname function retrieves host information corresponding to a host name from a host database.
gethostname
The gethostname function retrieves the standard host name for the local computer.
GetHostNameW
The GetHostNameW function retrieves the standard host name for the local computer as a Unicode string.
getpeername
The getpeername function retrieves the address of the peer to which a socket is connected.
getprotobyname
The getprotobyname function retrieves the protocol information corresponding to a protocol name.
getprotobynumber
getservbyname
The getservbyname function retrieves service information corresponding to a service name and protocol.
getservbyport
The getservbyport function retrieves service information corresponding to a port and protocol.
getsockname
getsockopt
htond
Converts a double from host to TCP/IP network byte order (which is big-endian).
htonf
Converts a float from host to TCP/IP network byte order (which is big-endian).
htonl
The htonl function converts a u_long from host to TCP/IP network byte order (which is big-endian).
htonll
Converts an unsigned __int64 from host to TCP/IP network byte order (which is big-endian).
htons
The htons function converts a u_short from host to TCP/IP network byte order (which is big-endian).
inet_addr
The inet_addr function converts a string containing an IPv4 dotted-decimal address into a proper address for the IN_ADDR
structure.
inet_ntoa
The inet_ntoa function converts an (Ipv4) Internet network address into an ASCII string in Internet standard dotted-decimal
format.
ioctlsocket
listen
The listen function places a socket in a state in which it is listening for an incoming connection.
ntohd
Converts an unsigned __int64 from TCP/IP network order to host byte order (which is little-endian on Intel processors) and
returns a double.
ntohf
Converts an unsigned __int32 from TCP/IP network order to host byte order (which is little-endian on Intel processors) and
returns a float.
ntohl
The ntohl function converts a u_long from TCP/IP network order to host byte order (which is little-endian on Intel processors).
ntohll
Converts an unsigned __int64 from TCP/IP network order to host byte order (which is little-endian on Intel processors).
ntohs
The ntohs function converts a u_short from TCP/IP network byte order to host byte order (which is little-endian on Intel
processors).
ProcessSocketNotifications
Associates a set of sockets with a completion port, and retrieves any notifications that are already pending on that port. Once
associated, the completion port receives the socket state notifications that were specified.
recv
recvfrom
The recvfrom function receives a datagram, and stores the source address.
select
The select function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O.
send
setsockopt
shutdown
socket
The socket function creates a socket that is bound to a specific transport service provider.
SocketNotificationRetrieveEvents
This inline helper function is provided as a convenience to retrieve the events mask from an OVERLAPPED_ENTRY.
WSAAccept
The WSAAccept function 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.
WSAAddressToStringA
Converts all components of a sockaddr structure into a human-readable string representation of the address.
WSAAddressToStringW
Converts all components of a sockaddr structure into a human-readable string representation of the address.
WSAAsyncGetHostByAddr
The WSAAsyncGetHostByAddr function asynchronously retrieves host information that corresponds to an address.Note The
WSAAsyncGetHostByAddr function is not designed to provide parallel resolution of several addresses.
WSAAsyncGetHostByName
The WSAAsyncGetHostByName function asynchronously retrieves host information that corresponds to a host
name.Note The WSAAsyncGetHostByName function is not designed to provide parallel resolution of several names.
WSAAsyncGetProtoByName
The WSAAsyncGetProtoByName function asynchronously retrieves protocol information that corresponds to a protocol name.
WSAAsyncGetProtoByNumber
The WSAAsyncGetProtoByNumber function asynchronously retrieves protocol information that corresponds to a protocol
number.
WSAAsyncGetServByName
The WSAAsyncGetServByName function asynchronously retrieves service information that corresponds to a service name and
port.
WSAAsyncGetServByPort
The WSAAsyncGetServByPort function asynchronously retrieves service information that corresponds to a port and protocol.
WSAAsyncSelect
WSACancelAsyncRequest
WSACancelBlockingCall
The WSACancelBlockingCall function has been removed in compliance with the Windows Sockets 2 specification, revision 2.2.0.
WSACleanup
WSACloseEvent
WSAConnect
The WSAConnect function establishes a connection to another socket application, exchanges connect data, and specifies
required 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).
WSAConnectByNameA
WSAConnectByNameW
WSACreateEvent
WSADuplicateSocketA
The WSADuplicateSocket function returns a WSAPROTOCOL_INFO structure that can be used to create a new socket
descriptor for a shared socket. The WSADuplicateSocket function cannot be used on a QOS-enabled socket.
WSADuplicateSocketW
The WSADuplicateSocket function returns a WSAPROTOCOL_INFO structure that can be used to create a new socket
descriptor for a shared socket. The WSADuplicateSocket function cannot be used on a QOS-enabled socket.
WSAEnumNameSpaceProvidersA
WSAEnumNameSpaceProvidersExA
WSAEnumNameSpaceProvidersExW
WSAEnumNameSpaceProvidersW
WSAEnumNetworkEvents
The WSAEnumNetworkEvents function discovers occurrences of network events for the indicated socket, clear internal network
event records, and reset event objects (optional).
WSAEnumProtocolsA
WSAEnumProtocolsW
WSAEventSelect
The WSAEventSelect function specifies an event object to be associated with the specified set of FD_XXX network events.
WSAGetLastError
Returns the error status for the last Windows Sockets operation that failed.
WSAGetOverlappedResult
The WSAGetOverlappedResult function retrieves the results of an overlapped operation on the specified socket.
WSAGetQOSByName
The WSAGetQOSByName function initializes a QOS structure based on a named template, or it supplies a buffer to retrieve an
enumeration of the available template names.
WSAGetServiceClassInfoA
The WSAGetServiceClassInfo function retrieves the class information (schema) pertaining to a specified service class from a
specified namespace provider.
WSAGetServiceClassInfoW
The WSAGetServiceClassInfo function retrieves the class information (schema) pertaining to a specified service class from a
specified namespace provider.
WSAGetServiceClassNameByClassIdA
The WSAGetServiceClassNameByClassId function retrieves the name of the service associated with the specified type. This
name is the generic service name, like FTP or SNA, and not the name of a specific instance of that service.
WSAGetServiceClassNameByClassIdW
The WSAGetServiceClassNameByClassId function retrieves the name of the service associated with the specified type. This
name is the generic service name, like FTP or SNA, and not the name of a specific instance of that service.
WSAHtonl
The WSAHtonl function converts a u_long from host byte order to network byte order.
WSAHtons
The WSAHtons function converts a u_short from host byte order to network byte order.
WSAInstallServiceClassA
WSAInstallServiceClassW
WSAIoctl
WSAIsBlocking
This function has been removed in compliance with the Windows Sockets 2 specification, revision 2.2.0.
WSAJoinLeaf
The WSAJoinLeaf function joins a leaf node into a multipoint session, exchanges connect data, and specifies needed quality of
service based on the specified FLOWSPEC structures.
WSALookupServiceBeginA
The WSALookupServiceBegin function initiates a client query that is constrained by the information contained within a
WSAQUERYSET structure.
WSALookupServiceBeginW
The WSALookupServiceBegin function initiates a client query that is constrained by the information contained within a
WSAQUERYSET structure.
WSALookupServiceEnd
The WSALookupServiceEnd function is called to free the handle after previous calls to WSALookupServiceBegin and
WSALookupServiceNext.
WSALookupServiceNextA
The WSALookupServiceNext function is called after obtaining a handle from a previous call to WSALookupServiceBegin in
order to retrieve the requested service information.
WSALookupServiceNextW
The WSALookupServiceNext function is called after obtaining a handle from a previous call to WSALookupServiceBegin in
order to retrieve the requested service information.
WSANSPIoctl
WSANtohl
The WSANtohl function converts a u_long from network byte order to host byte order.
WSANtohs
The WSANtohs function converts a u_short from network byte order to host byte order.
WSAPoll
WSAProviderConfigChange
The WSAProviderConfigChange function notifies the application when the provider configuration is changed.
WSARecv
WSARecvDisconnect
The WSARecvDisconnect function terminates reception on a socket, and retrieves the disconnect data if the socket is
connection oriented.
WSARecvFrom
WSARemoveServiceClass
The WSARemoveServiceClass function permanently removes the service class schema from the registry.
WSAResetEvent
The WSAResetEvent function resets the state of the specified event object to nonsignaled.
WSASend
The WSASendDisconnect function initiates termination of the connection for the socket and sends disconnect data.
WSASendMsg
Sends data and optional control information from connected and unconnected sockets. Note This function is a Microsoft-
specific extension to the Windows Sockets specification. .
WSASendTo
WSASetBlockingHook
This function has been removed in compliance with the Windows Sockets 2 specification, revision 2.2.0.
WSASetEvent
The WSASetEvent function sets the state of the specified event object to signaled.
WSASetLastError
The WSASetLastError function sets the error code that can be retrieved through the WSAGetLastError function.
WSASetServiceA
The WSASetService function registers or removes from the registry a service instance within one or more namespaces.
WSASetServiceW
The WSASetService function registers or removes from the registry a service instance within one or more namespaces.
WSASocketA
The WSASocket function creates a socket that is bound to a specific transport-service provider.
WSASocketW
The WSASocket function creates a socket that is bound to a specific transport-service provider.
WSAStartup
WSAStringToAddressA
The WSAStringToAddress function converts a network address in its standard text presentation form into its numeric binary
form in a sockaddr structure, suitable for passing to Windows Sockets routines that take such a structure.
WSAStringToAddressW
The WSAStringToAddress function converts a network address in its standard text presentation form into its numeric binary
form in a sockaddr structure, suitable for passing to Windows Sockets routines that take such a structure.
WSAUnhookBlockingHook
This function has been removed in compliance with the Windows Sockets 2 specification, revision 2.2.0.
WSAWaitForMultipleEvents
Returns when one or all of the specified event objects are in the signaled state, when the time-out interval expires, or when an
I/O completion routine has executed.
Callback functions
LPWSAOVERLAPPED_COMPLETION_ROUTINE
TBD
Structures
AFPROTOCOLS
The AFPROTOCOLS structure supplies a list of protocols to which application programmers can constrain queries. The
AFPROTOCOLS structure is used for query purposes only.
BLOB
The BLOB structure, derived from Binary Large Object, contains information about a block of data.
fd_set
Fd_set structure is used by Windows Sockets (Winsock) functions and service providers to place sockets into a set.
HOSTENT
The hostent structure is used by functions to store information about a given host, such as host name, IPv4 address, and so
forth.
in_addr
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.
PROTOENT
The protoent structure contains the name and protocol numbers that correspond to a given protocol name.
QOS
The QOS structure provides the means by which QOS-enabled applications can specify quality of service parameters for sent
and received traffic on a particular flow.
SERVENT
The servent structure is used to store or return the name and service number for a given service name.
SOCK_NOTIFY_REGISTRATION
TIMEVAL
The timeval structure is used to specify a time interval. It is associated with the Berkeley Software Distribution (BSD) Time.h
header file.
WSACOMPLETION
Specifies completion notification settings for I/O control calls made to a registered namespace.
WSADATA
WSANAMESPACE_INFOA
WSANAMESPACE_INFOEXA
WSANAMESPACE_INFOEXW
WSANAMESPACE_INFOW
WSANETWORKEVENTS
The WSANETWORKEVENTS structure is used to store a socket's internal information about network events.
WSANSCLASSINFOA
The WSANSCLASSINFO structure provides individual parameter information for a specific Windows Sockets namespace.
WSANSCLASSINFOW
The WSANSCLASSINFO structure provides individual parameter information for a specific Windows Sockets namespace.
WSAOVERLAPPED
Provides a communication medium between the initiation of an overlapped I/O operation and its subsequent completion.
WSAPOLLFD
WSAPROTOCOL_INFOA
WSAPROTOCOL_INFOW
WSAPROTOCOLCHAIN
The WSAPROTOCOLCHAIN structure contains a counted list of Catalog Entry identifiers that comprise a protocol chain.
WSAQUERYSET2A
Provides relevant information about a given service, including service class ID, service name , applicable namespace identifier
and protocol information, as well as a set of transport addresses at which the service listens.
WSAQUERYSET2W
Provides relevant information about a given service, including service class ID, service name , applicable namespace identifier
and protocol information, as well as a set of transport addresses at which the service listens.
WSAQUERYSETA
Provides relevant information about a given service, including service class ID, service name, applicable namespace identifier
and protocol information, as well as a set of transport addresses at which the service listens.
WSAQUERYSETW
Provides relevant information about a given service, including service class ID, service name, applicable namespace identifier
and protocol information, as well as a set of transport addresses at which the service listens.
WSASERVICECLASSINFOA
The WSASERVICECLASSINFO structure contains information about a specified service class. For each service class in Windows
Sockets 2, there is a single WSASERVICECLASSINFO structure.
WSASERVICECLASSINFOW
The WSASERVICECLASSINFO structure contains information about a specified service class. For each service class in Windows
Sockets 2, there is a single WSASERVICECLASSINFO structure.
WSAVERSION
Enumerations
WSAECOMPARATOR
The Windows Sockets WSAECOMPARATOR enumeration type is used for version-comparison semantics in Windows Sockets 2.