htons Function

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

Syntax

u_short WSAAPI htons(
  __in  u_short hostshort
);

Parameter

hostshort [in]

A 16-bit number in host byte order.

Rückgabewert

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

Hinweise

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.

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
inet_addr
inet_ntoa
InetNtop
ntohl
ntohs
WSAHtonl
WSAHtons
WSANtohl
WSANtohs

 

 

Anzeigen: