There are four functions for byte sequence conversion. For 2 bytes and 4 bytes respectively. A single byte naturally has no issue with the byte sequence.
Htonl (3)-Linux man pagename
Htonl, htons, ntohl, ntohs-convert values between host and network byte order
Synopsis
#include <arpa/inet.h>uint32_t htonl(uint32_t hostlong);uint16_t htons(uint16_t hostshort);uint32_t ntohl(uint32_t netlong);uint16_t ntohs(uint16_t netshort);
Description
TheHtonl() Function converts the unsigned integerHostlongFrom host byte order to network byte order.
TheHtons() Function converts the unsigned short integerHostshortFrom host byte order to network byte order.
TheNtohl() Function converts the unsigned integerNetlongFrom Network byte order to host byte order.
TheNtohs() Function converts the unsigned short integerNetshortFrom Network byte order to host byte order.
On the i80x86 the host byte order is least significant byte first, whereas the network byte order, as used on the Internet, is most significant byte first.
Conforming
POSIX.1-2001.
Some systems require the regression sion<Netinet/in. h>Instead<ARPA/inet. h>.
See also
Gethostbyname(3),Getservent(3)