BYTEORDER(3) Linux Programmer's Manual BYTEORDER(3)
名
htonl, htons, ntohl, ntohs -
ホストバイトオーダーとネットワークバイトオーダーの間で値を変換する
書
#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);
説
htonl() 関数は unsigned integer hostlong を
ホストバイトオーダーからネットワークバイトオーダーに変換する。
htons() 関数は unsigned short integer hostshort を
ホストバイトオーダーからネットワークバイトオーダーに変換する。
ntohl() 関数は unsigned integer netlong を
ネットワークバイトオーダーからホストバイトオーダーに変換する。
ntohs() 関数は unsigned short integer netshort を
ネットワークバイトオーダーからホストバイトオーダーに変換する。
i80x86 のホストバイトオーダーでは最下位バイトが若いアドレスに配置されるが、
インターネットで用いられるネットワークバイトオーダーでは最上位バイト が先に配置される。
属
マ
関数 htonl(), htons(), ntohl(), ntohs() はスレッドセーフである。
準
POSIX.1-2001.
いくつかのシステムでは、 <arpa/inet.h> の代わりに <netinet/in.h>
をインクルードする必要がある。
こ
この man ページは Linux man-pages プロジェクトのリリース 3.79 の一部
である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man-pages/
に書かれている。
GNU 2014-04-08 BYTEORDER(3)