htons

The Windows Sockets htons function converts a u_short from host to TCP/IP network byte order (which is big-endian).

u_short htons (
  u_short hostshort  
);
 

Parameters

hostshort
[in] A 16-bit number in host byte order.

Remarks

The htons function takes a 16-bit number in host byte order and returns a 16-bit number in network byte order used in TCP/IP networks.

Return Values

The htons function returns the value in TCP/IP network byte order.

QuickInfo

  Windows NT: Yes
  Windows: Yes
  Windows CE: Use version 1.0 and later.
  Header: Declared in winsock2.h.
  Import Library: Link with ws2_32.lib.

See Also

htonl, ntohl, ntohs, WSAHtonl, WSAHtons, WSANtohl, WSANtohs