h_errno
2016-06-16 15:04
369 查看
#include <stdio.h> #include <netdb.h> #include <iostream> #include <string.h> #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> using namespace std; int main(int argc, char *argv []) { char sz [] = "Hello, World!"; //Hover mouse over "sz" while debugging to see its contents cout << sz << endl; //<================= Put a breakpoint here //打印错误网络信息 char szError [] = "err:"; herror(szError); extern int h_errno; for (int i=0;i<5;i++) { printf("%d---%s\n", i, hstrerror(i)); } int port = 1234; printf("%d\n", htons(port)); //转换网络字节序 //53764 printf("%d\n", ntohs(htons(port))); //转换本地字节序 //1234 struct in_addr ip; ip.s_addr = 16777343; printf("%s\n", inet_ntoa(ip)); //127.0.0.1 char szip [] = "127.0.0.1"; printf("%d\n", inet_addr(szip));//16777343 return 0; } /* Hello, World! err:: Resolver Error 0 (no error) 0---Resolver Error 0 (no error) 1---Unknown host 2---Host name lookup failure 3---Unknown server error 4---No address associated with name 53764 1234 127.0.0.1 16777343 */
相关文章推荐
- Android--Demo_PullToRefresh(特效篇)
- xampp1.7 版本 安装步骤 以及mysql配置
- Python3 正则表达式
- 读取java项目下的文件
- 随笔-学习工具、教程 推荐
- Fragment生命周期
- 信息论、最大熵模型
- spring配置错误Could not find acceptable representation
- HTML5 - 用<figure/>添加插图和图题
- 【Java】内部类与外部类的互访使用小结
- TGroupon分销系统 delete_cart_goods.php 漏洞修复
- 关于IE中image的onload事件失效解决问题
- Saltstack SLS文件解读
- 如何在项目启动的时候做一些业务处理 (实现ServletContextListener)
- oracle游标透彻详解分析
- iOS 9 Spotlight搜索 OC版
- php-代码优化准则
- Mac使用zsh导致maven命令无效的解决方案
- Spring配置数据库的连接
- Head_First设计模式(一)----策略模式