Share via


WSANtohs

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function converts a u_short from network byte order to host byte order.

Syntax

int WSANtohs(
  SOCKET s,
  u_short netshort,
  u_short FAR* lphostshort
);

Parameters

  • s
    [in] Descriptor identifying a socket.
  • netshort
    [in] 16-bit number in network byte order.
  • lphostshort
    [out] Pointer to a 16-bit number in host byte order.

Return Value

If no error occurs, this function returns zero. If an error occurs, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling the WSAGetLastError function. The following table shows a list of possible error codes.

Error code Description

WSANOTINITIALISED

A successful WSAStartup call must occur before using this function.

WSAENETDOWN

The network subsystem has failed.

WSAENOTSOCK

The descriptor is not a socket.

WSAEFAULT

The lphostshort parameter is not completely contained in a valid part of the user address space.

Remarks

This function takes a 16-bit number in the network byte order associated with socket s and returns a 16-bit number pointed to by the lphostshort parameter in host byte order.

Requirements

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

See Also

Reference

htonl
htons
ntohl
ntohs
WSAHtonl
WSANtohl
WSAHtons
WSAGetLastError
WSAStartup