在执行网络I/O时, 要做的第一件事就是调用socket函数. 函数原型 #include <sys/socket.h> int socket(int family, int type, int protocol); 成功 : 返回非负描述符. 失败 : 返回-1, 设置errno的值. 函数错误时返回-1, 但是也会设置相应的errno的值 : 值 含义 EACCES 没有权限建立制定的domain的type的socket EAFNOSUPPORT 不支持所给的地址类型 EINVAL