网络大小端转换函数
2016-08-26 15:35
302 查看
网络大小端转换函数
//***************************************************************************** // // htonl/ntohl - big endian/little endian byte swapping macros for // 32-bit (long) values // //***************************************************************************** #ifndef htonl static uint32_t htonl(uint32_t a) { return ((a >> 24) & 0x000000ff) | ((a >> 8) & 0x0000ff00) | ((a << 8) & 0x00ff0000) | ((a << 24) & 0xff000000); } #endif #ifndef ntohl #define ntohl(a) htonl((a)) #endif //***************************************************************************** // // htons/ntohs - big endian/little endian byte swapping macros for // 16-bit (short) values // //***************************************************************************** #ifndef htons static uint16_t htons(uint16_t a) { return ((a >> 8) & 0x00ff) | ((a << 8) & 0xff00); } #endif #ifndef ntohs #define ntohs(a) htons((a)) #endif
相关文章推荐
- DOS网络命令全集
- 网络流行词
- ArcGIS.Server.9.2.DotNet网络分析之最短路径分析
- 计算机网络等级三级考试
- Linux网络资源
- 网络营销和营销体验设计这两者的关联在哪里?
- 笔记本间无线网络共享方法
- 网络攻击技术(三)——Denial Of Service
- each用法(网络摘抄)
- Cisco路由配置-Boson NetSim for CCNP v6(模拟器)--网络实验5.5
- iOS网络编程-iCloud文档存储编程实例
- 测试网络连接的时间 tracert及其其它常用命令
- windows上的网络基础库
- UIActivityIndicatorView(活动指示器 ---------> 网络卡后加载,画面,图像加载闪烁的圆圈)
- 网络命令总结(Cisco Packet Tracer)
- 网络购物新思维 精品消费更省钱
- 网络相关命令
- Linux环境下服务器和客户端的网络通信
- 工具类:处理网络请求的回应