UID | title | description | helpviewer_keywords | old-location | tech.root | ms.assetid | ms.date | ms.keywords | req.header | req.include-header | req.target-type | req.target-min-winverclnt | req.target-min-winversvr | req.kmdf-ver | req.umdf-ver | req.ddi-compliance | req.unicode-ansi | req.idl | req.max-support | req.namespace | req.assembly | req.type-library | req.lib | req.dll | req.irql | targetos | req.typenames | req.redist | ms.custom | f1_keywords | dev_langs | topic_type | api_type | api_location | api_name | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
NF:winsock2.htons |
htons function (winsock2.h) |
The htons function (winsock2.h) converts a u_short from host to TCP/IP network byte order, which is big-endian. |
|
winsock\htons_2.htm |
WinSock |
3dae2655-2b3c-41d9-9650-125ac393d64a |
08/03/2022 |
_win32_htons_2, htons, htons function [Winsock], winsock.htons_2, winsock/htons |
winsock2.h |
Winsock2.h |
Windows |
Windows 8.1, Windows Vista [desktop apps \| UWP apps] |
Windows Server 2003 [desktop apps \| UWP apps] |
Ws2_32.lib |
Ws2_32.dll |
Windows |
19H1 |
|
|
|
|
|
|
The htons function converts a u_short from host to TCP/IP network byte order (which is big-endian).
A 16-bit number in host byte order.
The htons function returns the value in TCP/IP network byte order.
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 (the AF_INET or AF_INET6 address family).
The htons function can be used to convert an IP port number in host byte order to the IP port number in network byte order.
The htons function does not require that the Winsock DLL has previously been loaded with a successful call to the WSAStartup function.
Windows 8.1 and Windows Server 2012 R2: This function is supported for Windows Store apps on Windows 8.1, Windows Server 2012 R2, and later.