Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function converts a u_shortfrom host to TCP/IP network byte order, which is big-endian.

Syntax

u_short htons(
  u_short 
hostshort
);

Parameters

hostshort

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

Remarks

This 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 Value

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

Requirements

Header winsock2.h
Library Ws2.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also