logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

htonl, htons, ntohl, ntohs - convert values between host and network byte order

Attributes

       For an explanation of the terms used in this section, see attributes(7).
       ┌─────────────────────────────────────────────────────────────────────────────┬───────────────┬─────────┐
       │ InterfaceAttributeValue   │
       ├─────────────────────────────────────────────────────────────────────────────┼───────────────┼─────────┤
       │ htonl(), htons(), ntohl(), ntohs()                                          │ Thread safety │ MT-Safe │
       └─────────────────────────────────────────────────────────────────────────────┴───────────────┴─────────┘

Description

       The htonl() function converts the unsigned integer hostlong from host byte order to network byte order.

       The  htons()  function converts the unsigned short integer hostshort from host byte order to network byte
       order.

       The ntohl() function converts the unsigned integer netlong from network byte order to host byte order.

       The ntohs() function converts the unsigned short integer netshort from network byte order  to  host  byte
       order.

       On  the i386 the host byte order is Least Significant Byte first, whereas the network byte order, as used
       on the Internet, is Most Significant Byte first.

History

       POSIX.1-2001.

Library

       Standard C library (libc, -lc)

Name

       htonl, htons, ntohl, ntohs - convert values between host and network byte order

See Also

bswap(3), endian(3), gethostbyname(3), getservent(3)

Linux man-pages 6.9.1                              2024-05-02                                       BYTEORDER(3)

Standards

       POSIX.1-2008.

Synopsis

#include<arpa/inet.h>uint32_thtonl(uint32_thostlong);uint16_thtons(uint16_thostshort);uint32_tntohl(uint32_tnetlong);uint16_tntohs(uint16_tnetshort);

See Also