Click to Rate and Give Feedback
MSDN
MSDN Library
Networking
Network Protocols
Windows Sockets 2
Winsock Reference
Winsock Functions
 ntohs Function
ntohs Function

The ntohs function converts a u_short from TCP/IP network byte order to host byte order (which is little-endian on Intel processors).

Syntax

C++
u_short WSAAPI ntohs(
  __in  u_short netshort
);

Parameters

netshort [in]

A 16-bit number in TCP/IP network byte order.

Return Value

The ntohs function returns the value in host byte order. If the netshort parameter is already in host byte order, then this function will reverse it. It is up to the application to determine if the byte order must be reversed.

Remarks

The ntohs function takes a 16-bit number in TCP/IP network byte order (the AF_INET or AF_INET6 address family) and returns a 16-bit number in host byte order.

The ntohs function can be used to convert an IP port number in network byte order to the IP port number in host byte order.

The ntohs function does not require that the Winsock DLL has previously been loaded with a successful call to the WSAStartup function.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinsock2.h
LibraryWs2_32.lib
DLLWs2_32.dll

See Also

Winsock Reference
Winsock Functions
htonl
htons
inet_addr
inet_ntoa
InetNtop
ntohl
WSAHtonl
WSAHtons
WSANtohl
WSANtohs

Send comments about this topic to Microsoft

Build date: 10/29/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker