WSANtohs Function
The WSANtohs function converts a u_short from network byte order to host byte order.
Syntax
int WSAAPI WSANtohs(
__in SOCKET s,
__in u_short netshort,
__out u_short *lphostshort
);
Parameter
s [in]
A descriptor identifying a socket.netshort [in]
A 16-bit number in network byte order.lphostshort [out]
A pointer to a 16-bit number to receive the number in host byte order.
Rückgabewert
If no error occurs, WSANtohs returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
Error code | Meaning |
---|---|
WSANOTINITIALISED | A successful WSAStartup call must occur before using this function. |
WSAENETDOWN | The network subsystem has failed. |
WSAENOTSOCK | The descriptor is not a socket. |
WSAEFAULT | The lphostshort parameter is NULL or the address pointed to is not completely contained in a valid part of the user address space. |
Hinweise
The WSANtohs function takes a 16-bit number in network byte order and returns a 16-bit number in host byte order in the 16-bit number pointed to by the lphostshort parameter. The socket passed in the s parameter is used to determine the network byte order required based on the Winsock catalog protocol entry associated with the socket. This feature supports Winsock providers that use different network byte orders.
If the socket is for the AF_INET or AF_INET6 address family, the WSANtohs function can be used to convert an IP port number in network byte order to the IP port number in host byte order.
The WSANtohs function requires that the Winsock DLL has previously been loaded with a successful call to the WSAStartup function. For use with the AF_INET OR AF_INET6 address family, the ntohs function does not require that the Winsock DLL be loaded.
Anforderungen
Mindestens unterstützter Client |
Windows 2000 Professional |
Mindestens unterstützter Server |
Windows 2000 Server |
Header |
Winsock2.h |
Bibliothek |
Ws2_32.lib |
DLL |
Ws2_32.dll |