-
Notifications
You must be signed in to change notification settings - Fork 53
gethostbyname
果冻虾仁 edited this page Jan 29, 2015
·
6 revisions
##函数原型
#include <netdb.h>
extern int h_errno;
struct hostent *gethostbyname(const char *name);
#include <sys/socket.h> /* for AF_INET *//*貌似不加也可以*/
struct hostent *gethostbyaddr(const void *addr,
socklen_t len, int type);
Talk is cheap, show me the code!
C语言API包含部分
标准C的API、POSIX标准的系统编程API(一些Linux独有的系统API会单独注明)。
大部分头文件源码在/usr/include
目录下。
因为涉及到大量的POSIX编程。所以最好下载POSIX函数的man手册。
apt-get install manpages-posix
apt-get install manpages-posix-dev
默认安装了manpages-dev
,所以不装POSIX的man手册是可以查看绝大部分API的。
但是不装的话,有些API是不能看到的,比如posix_spawn
函数。
yum install man-pages.noarch
关于目录
左侧的目录并非以函数为索引依据,主要是以系统的man手册页面为索引依据。
比如exec里面包含6个函数、pipe里面包含pipe()和pipe2()两个函数,但是它们都是属于一个man页面中。