摘要: #include <sys/socket.h> /*返回:若成功则为非负描述符,若出错则为-1*/ int socket(int family, int type, int protocol); family参数指明协议族,也常被称为协议域; AF_INET IPv4协议 AF_INET6 IPv6 阅读全文
posted @ 2022-09-06 18:13 东宫得臣 阅读(19) 评论(0) 推荐(0) 编辑
摘要: IPv4 socket地址结构通常也称为“网际socket地址结构”,它以sockaddr_in命名,定义在<netinet/in.h> struct in_addr { in_addr_t s_addr; /*32-bit IPv4 address*/ }; struct sockaddr_in 阅读全文
posted @ 2022-09-06 17:32 东宫得臣 阅读(119) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #include <string.h> c 阅读全文
posted @ 2022-09-06 15:05 东宫得臣 阅读(13) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <netinet/in.h> #include <time.h> #include <errno.h> #include <string.h> const 阅读全文
posted @ 2022-09-06 15:02 东宫得臣 阅读(40) 评论(0) 推荐(0) 编辑