Beej’s Guide Network to Programming 系列连载18
来源:互联网 发布:查询数据库表名称 编辑:程序博客网 时间:2024/05/22 09:50
5.11. gethostname() ---我是谁?
甚至比getpeername() 还简单的函数是 gethostname()。它返回你程序所运行的机器的主机名字。然后你可以使用 gethostbyname() 以获得你的机器的 IP 地址。
下面是定义:
#include <unistd.h>
intgethostname(char *hostname, size_t size);
参数很简单:hostname是一个字符数组指针,它将在函数返回时保存
主机名。size是hostname 数组的字节长度。
函数调用成功时返回 0,失败时返回 -1,并设置 errno。
- Beej’s Guide Network to Programming 系列连载18
- Beej’s Guide Network to Programming 系列连载01
- Beej’s Guide Network to Programming 系列连载02
- Beej’s Guide Network to Programming 系列连载03
- Beej’s Guide Network to Programming 系列连载04
- Beej’s Guide Network to Programming 系列连载05
- Beej’s Guide Network to Programming 系列连载06
- Beej’s Guide Network to Programming 系列连载07
- Beej’s Guide Network to Programming 系列连载08
- Beej’s Guide Network to Programming 系列连载09
- Beej’s Guide Network to Programming 系列连载10
- Beej’s Guide Network to Programming 系列连载11
- Beej’s Guide Network to Programming 系列连载12
- Beej’s Guide Network to Programming 系列连载13
- Beej’s Guide Network to Programming 系列连载14
- Beej’s Guide Network to Programming 系列连载15
- Beej’s Guide Network to Programming 系列连载16
- Beej’s Guide Network to Programming 系列连载17
- 理解 Android 本地数据存储 API--利用首选项、SQLite 和内部及外部内存 API
- Beej’s Guide Network to Programming 系列连载17
- Postfix+Dovecot搭建MailServer配置说明
- 重启Oracle的方法(win7)
- 查看SqlServer数据库连接状态
- Beej’s Guide Network to Programming 系列连载18
- (转)hadoop 命令手册
- gridview
- hash冲突导致ddos,详细跟踪
- sql substring 用法
- HDU1254 推箱子 BFS+优先队列
- WindowsAPI的时间结构体、时间转换及时间获取
- 搜索
- 【那些年,我们一起追的女孩】第六章