Windows Sockets (Winsock) Reference

References for the Windows Sockets (Winsock) API on Xbox One.

Winsock Error Codes

Functions

Name Description
__WSAFDIsSet Specifies whether a socket is included in a set of socket descriptors.
accept The accept function permits an incoming connection attempt on a socket.
bind Associates a local address with a socket.
closesocket The closesocket function closes an existing socket.
connect The connect function establishes a connection to a specified socket.
gethostbyaddr
Note gethostbyaddr is no longer recommended for use as of Windows Sockets 2. Instead, use getnameinfo.
The gethostbyaddr function retrieves the host information corresponding to a network address.
gethostbyname The gethostbyname function retrieves host information corresponding to a host name from a host database.
Note The gethostbyname function has been deprecated by the introduction of the getaddrinfo function. Developers creating Windows Sockets 2 applications are urged to use the getaddrinfo function instead of gethostbyname.
gethostname The gethostname function retrieves the standard host name for the local computer.
GetHostNameW The gethostname function retrieves the standard host name for the local computer.
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 The getprotobynumber function retrieves protocol information corresponding to a protocol number.
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 The getsockname function retrieves the local name for a socket.
getsockopt The getsockopt function retrieves a socket option.
htonl The htonl function converts a u_long 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 The ioctlsocket function controls the I/O mode of a socket.
listen The listen function places a socket in a state in which it is listening for an incoming connection.
ntohl The ntohl function converts a u_long 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).
recv The recv function receives data from a connected socket or a bound connectionless socket.
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 The send function sends data on a connected socket.
sendto The sendto function sends data to a specific destination.
setsockopt The setsockopt function sets a socket option.
shutdown The shutdown function disables sends or receives on a socket.
socket The socket function creates a socket that is bound to a specific transport service provider.
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 The WSAAddressToString function converts all components of a sockaddr structure into a human-readable string representation of the address.This is intended to be used mainly for display purposes. If the caller requires that the translation to be performed by a particular provider, it should supply the corresponding WSAPROTOCOL_INFO structure in the lpProtocolInfo parameter.
WSAAddressToStringW The WSAAddressToString function converts all components of a sockaddr structure into a human-readable string representation of the address.This is intended to be used mainly for display purposes. If the caller requires that the translation to be performed by a particular provider, it should supply the corresponding WSAPROTOCOL_INFO structure in the lpProtocolInfo parameter.
WSACancelBlockingCall Deprecated. Do not use.
WSACleanup The WSACleanup function terminates use of the Winsock 2 DLL (Ws2_32.dll).
WSACloseEvent The WSACloseEvent function closes an open event object handle.
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.
WSAConnectByNameA The WSAConnectByName function establishes a connection to a specified host and port. This function is provided to allow a quick connection to a network endpoint given a host name and port.This function supports both IPv4 and IPv6 addresses.
WSAConnectByNameW The WSAConnectByName function establishes a connection to a specified host and port. This function is provided to allow a quick connection to a network endpoint given a host name and port.This function supports both IPv4 and IPv6 addresses.
WSACreateEvent The WSACreateEvent function creates a new event object.
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 The WSAEnumNameSpaceProviders function retrieves information on available namespace providers.
WSAEnumNameSpaceProvidersExA The WSAEnumNameSpaceProvidersEx function retrieves information on available namespace providers.
WSAEnumNameSpaceProvidersExW The WSAEnumNameSpaceProvidersEx function retrieves information on available namespace providers.
WSAEnumNameSpaceProvidersW The WSAEnumNameSpaceProviders function retrieves information on available namespace providers.
WSAEnumNetworkEvents The WSAEnumNetworkEvents function discovers occurrences of network events for the indicated socket, clear internal network event records, and reset event objects (optional).
WSAEnumProtocolsA The WSAEnumProtocols function retrieves information about available transport protocols.
WSAEnumProtocolsW The WSAEnumProtocols function retrieves information about available transport protocols.
WSAEventSelect The WSAEventSelect function specifies an event object to be associated with the specified set of FD_XXX network events.
WSAGetLastError The WSAGetLastError function 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 The WSAInstallServiceClass function registers a service class schema within a namespace. This schema includes the class name, class identifier, and any namespace-specific information that is common to all instances of the service, such as the SAP identifier or object identifier.
WSAInstallServiceClassW The WSAInstallServiceClass function registers a service class schema within a namespace. This schema includes the class name, class identifier, and any namespace-specific information that is common to all instances of the service, such as the SAP identifier or object identifier.
WSAIoctl The WSAIoctl function controls the mode of a socket.
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. WSALookupServiceBegin only returns a handle, which should be used by subsequent calls to WSALookupServiceNext to get the actual results.
WSALookupServiceBeginW The WSALookupServiceBegin function initiates a client query that is constrained by the information contained within a WSAQUERYSET structure. WSALookupServiceBegin only returns a handle, which should be used by subsequent calls to WSALookupServiceNext to get the actual results.
WSALookupServiceEnd The WSALookupServiceEnd function is called to free the handle after previous calls to WSALookupServiceBegin and WSALookupServiceNext. If you call WSALookupServiceEnd from another thread while an existing WSALookupServiceNext is blocked, the end call will have the same effect as a cancel and will cause the WSALookupServiceNext call to return immediately.
WSALookupServiceNextA The WSALookupServiceNext function is called after obtaining a handle from a previous call to WSALookupServiceBegin in order to retrieve the requested service information.The provider will pass back a WSAQUERYSET structure in the lpqsResults buffer. The client should continue to call this function until it returns WSA_E_NO_MORE, indicating that all of WSAQUERYSET has been returned.
WSALookupServiceNextW The WSALookupServiceNext function is called after obtaining a handle from a previous call to WSALookupServiceBegin in order to retrieve the requested service information.The provider will pass back a WSAQUERYSET structure in the lpqsResults buffer. The client should continue to call this function until it returns WSA_E_NO_MORE, indicating that all of WSAQUERYSET has been returned.
WSANSPIoctl The Windows Sockets WSANSPIoctl function enables developers to make I/O control calls to a registered namespace.
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.
WSAProviderConfigChange The WSAProviderConfigChange function notifies the application when the provider configuration is changed.
WSARecv The WSARecv function receives data from a connected socket or a bound connectionless socket.
WSARecvDisconnect The WSARecvDisconnect function terminates reception on a socket, and retrieves the disconnect data if the socket is connection oriented.
WSARecvFrom The WSARecvFrom function receives a datagram and stores the source address.
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 WSASend function sends data on a connected socket.
WSASendDisconnect The WSASendDisconnect function initiates termination of the connection for the socket and sends disconnect data.
WSASendTo The WSASendTo function sends data to a specific destination, using overlapped I/O where applicable.
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 WSAStartup initiates use of the Winsock DLL by a process.
Note The network stack for a Xbox One title does not start up immediately when the title is launched. WSAStartup should therefore be deferred until the title has confirmed network connectivity. The best approach for this is to wait until the title is full loaded or call ConnectionProfile.GetNetworkConnectivityLevel and ensure that the XboxLiveAccess connectivity level is returned.
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.
WSAWaitForMultipleEvents The WSAWaitForMultipleEvents function 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.

Structures

Name Description
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 The fd_set structure is used by various Windows Sockets functions and service providers, such as the select function, to place sockets into a “set” for various purposes, such as testing a given socket for readability using the readfds parameter of the select function.
HOSTENT The hostent structure is used by functions to store information about a given host, such as host name, IPv4 address, and so forth. An application should never attempt to modify this structure or to free any of its components. Furthermore, only one copy of the hostent structure is allocated per thread, and an application should therefore copy any information that it needs before issuing any other Windows Sockets API calls.
LINGER The linger structure 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. Applications must never attempt to modify this structure or to free any of its components. Furthermore, only one copy of this structure is allocated per thread, and therefore, the application should copy any information it needs before issuing any other Windows Sockets function calls.
QOS Xbox One does not support Winsock’s Quality of Service (QoS) feature.
SERVENT The servent structure is used to store or return the name and service number for a given service name.
TIMEVAL The timeval structure is used to specify a time interval. It is associated with the Berkeley Software Distribution (BSD) Time.h header file.
WSADATA The WSADATA structure contains information about the Windows Sockets implementation.
WSANAMESPACE_INFOA The WSANAMESPACE_INFO structure contains all registration information for a namespace provider.
WSANAMESPACE_INFOEXA The WSANAMESPACE_INFOEX structure contains all registration information for a namespace provider.
WSANAMESPACE_INFOEXW The WSANAMESPACE_INFOEX structure contains all registration information for a namespace provider.
WSANAMESPACE_INFOW The WSANAMESPACE_INFO structure contains all registration information for a namespace provider.
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.
WSAOVERLAPPED The WSAOVERLAPPED structure provides a communication medium between the initiation of an overlapped I/O operation and its subsequent completion. The WSAOVERLAPPED structure is compatible with the Windows OVERLAPPED structure.
WSAPOLLFD The WSAPOLLFD structure stores socket information used by the WSAPoll function.
WSAPROTOCOL_INFOA The WSAPROTOCOL_INFO structure is used to store or retrieve complete information for a given protocol.
WSAPROTOCOL_INFOW The WSAPROTOCOL_INFO structure is used to store or retrieve complete information for a given protocol.
WSAPROTOCOLCHAIN The WSAPROTOCOLCHAIN structure contains a counted list of Catalog Entry identifiers that comprise a protocol chain.
WSAQUERYSET2A The WSAQUERYSET2 structure 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 The WSAQUERYSET2 structure 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 The WSAQUERYSET structure 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 The WSAVERSION structure provides version comparison in Windows Sockets.

Enumerations

Name Description
WSACOMPLETIONTYPE The WSACOMPLETION structure specifies completion notification settings for I/O control calls made to a registered namespace.
WSAECOMPARATOR The Windows Sockets WSAECOMPARATOR enumeration type is used for version-comparison semantics in Windows Sockets 2.
WSAESETSERVICEOP The NSPSetService function registers or deregisters a service instance within a namespace.

See also

Introduction to Winsock on Xbox One

Secure Sockets Introduction