当前位置:首页 科普知识 htonl()

htonl()

发布时间:2023-09-14 18:27:51

将主机数转换成无符号长整型的网络字节顺序。本函数将一个32位数从主机字节顺序转换成网络字节顺序。

htonl()介绍

将主机数转换成无符号长整型的网络字节顺序。本函数将一个32位数从主机字节顺序转换成网络字节顺序。

htonl()

htonl()简述

将主机数转换成无符号长整形的网络字节顺序。

#include

uint32_t htonl(uint32_t hostlong);

hostlong:主机字节顺序表达的32位数。

htonl()注释

本函数将一个32位数从主机字节顺序转换成网络字节顺序。

htonl()用法

htonl()返回值

htonl()返回一个网络字节顺序的值。

参见:

htons(),ntohl(),ntohs().

htonl()Linux

在Linux系统下:

#include

uint32_t htonl(uint32_t hostlong);

htonl()

有些系统包含的头文件是 而不是 .

htonl()相关函数

uint16_t htons(uint16_t hostshort);

uint32_t ntohl(uint32_t netlong);

uint16_t ntohs(uint16_t netshort);

网际协议在处理这些多字节整数时,使用大端字节序。

在主机本身就使用大端字节序时,这些函数通常被定义为空宏。

htonl()MSDN原文

This function converts au_longfrom host to TCP/IP network byte order, which is big-endian.

u_long htonl(u_longhostlong);Parameters

hostlong

32-bit number in host byte order.

Return Values

htonl()

This function returns the value in TCP/IP network byte order.

Remarks

This function takes a 32-bit number in host byte order and returns a 32-bit number in the network byte order used in TCP/IP networks.

htonl,其实是host to network, l 的意思是返回类型是long

温馨提示:
本文【htonl()】由作者 爱百科 转载提供。 该文观点仅代表作者本人, 自学教育网 信息发布平台,仅提供信息存储空间服务, 若存在侵权问题,请及时联系管理员或作者进行删除。
(c)2008-2025 自学教育网 All Rights Reserved 汕头市灵创科技有限公司
粤ICP备2024240640号-6