WSAHtons

The Windows Sockets WSAHtons function converts a u_short from host byte order to network byte order.

int WSAHtons (
  SOCKET s,                 
  u_short hostshort,        
  u_short FAR * lpnetshort  
);
 

Parameters

s
[in] A descriptor identifying a socket.
hostshort
[in] A 16-bit number in host byte order.
lpnetshort
[out] A pointer to a 16-bit number in network byte order.

Remarks

The WSAHtons function takes a 16-bit number in host byte order and returns a 16-bit number pointed to by the lpnetshort parameter in the network byte order associated with socket s.

Return Values

If no error occurs, WSAHtons returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

Error Codes

WSANOTINITIALISED A successful WSAStartup must occur before using this function.
WSAENETDOWN The network subsystem has failed.
WSAENOTSOCK The descriptor is not a socket.
WSAEFAULT The lpnetshort parameter is not completely contained in a valid part of the user address space.

QuickInfo

  Windows NT: Yes
  Windows: Yes
  Windows CE: Unsupported.
  Header: Declared in winsock2.h.
  Import Library: Link with ws2_32.lib.

See Also

htonl, htons, ntohl, ntohs, WSAHtonl, WSANtohl, WSANtohs