WSAHtonl Function

The WSAHtonl function converts a u_long from host byte order to network byte order.

Syntax

int WSAAPI WSAHtonl(
  __in   SOCKET s,
  __in   u_long hostlong,
  __out  u_long *lpnetlong
);

Parameter

  • s [in]
    A descriptor identifying a socket.

  • hostlong [in]
    A 32-bit number in host byte order.

  • lpnetlong [out]
    A pointer to a 32-bit number to receive the number in network byte order.

Rückgabewert

If no error occurs, WSAHtonl 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 lpnetlong parameter is NULL or the address pointed to is not completely contained in a valid part of the user address space.

 

Hinweise

The WSAHtonl function takes a 32-bit number in host byte order and returns a 32-bit number in network byte order in the 32-bit number pointed to by the lpnetlong 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 WSAHtonl function can be used to convert an IPv4 address in host byte order to the IPv4 address in network byte order. This function does not do any checking to determine if the hostlong parameter is a valid IPv4 address.

The WSAHtonl 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 family, the htonl 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

Siehe auch

Winsock Reference

Winsock Functions

htonl

htons

inet_addr

inet_ntoa

InetNtop

ntohl

ntohs

WSANtohl

WSAHtons

WSANtohs