htons - Convert an unsigned short (16-bit) integer from
host byte order to network byte order
#include <arpa/inet.h>
in_port_t htons(
in_port_t hostshort );
Standard C Library (libc)
Interfaces documented on this reference page conform to
industry standards as follows:
htons(): XNS4.0, XNS5.0
Refer to the standards(5) reference page for more information
about industry standards and associated tags.
Specifies a 16-bit integer in host byte order.
The htons() (host-to-network short) function converts an
unsigned short (16-bit) integer from host byte order to
Internet network-byte order.
The Internet network requires address and port reference
data in network-byte order. Use the htons() function to
convert address and port short integers from host byte
order to Internet network-byte order.
Upon successful completion, the htons() function returns a
16-bit short integer in Internet network-byte order.
Current industry standards do not define error values for
the htons() function.
Functions: endhostent(3), endservent(3), htonl(3),
ntohl(3), ntohs(3).
Standards: standards(5).
Network Programmer's Guide
htons(3)
[ Back ] |