UNIX网络编程
永远的烟火
我就是我,为绚丽绽放而厚积薄发的人间烟火
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
IO复用-Select
函数原型: nt select(int maxfdp,fd_set *readfds,fd_set *writefds,fd_set *errorfds,struct timeval *timeout); 经典的Unix select系统调用: for( ;; ) { tv.tv_sec = 30; tv.tv_usec = 0; FD_ZERO( &rfds ); FD_SET原创 2020-08-04 19:45:08 · 136 阅读 · 0 评论 -
TCP并发服务器模型(2)
四、IO复用循环服务器 将系统的处理能力集中在核心业务上,降低并发处理单元的数量。 建立两个线程:一个处理客户端的连接请求 thread_connect,一个处理客户端的业务处理请求 thread_handle。 accept 成功后,thread_connect 将accept 返回的 fd 放入客户端连接状态表,此表与 thread_handle 共享。 thread_handle 建立 f...原创 2020-03-19 20:38:38 · 199 阅读 · 0 评论 -
TCP并发服务器模型(1)
1、统一accept,fork进程处理每一个客户端的业务 2、统一accept,create线程处理每一个客户端的业务 3、创建线程处理每一个客户端的请求,互斥处理每一个accept ...原创 2020-03-19 20:20:08 · 272 阅读 · 0 评论 -
IO模型
五中IO模型 阻塞IO 非阻塞IO IO复用 信号驱动IO 异步IO原创 2020-03-12 19:45:52 · 140 阅读 · 0 评论 -
数据IO函数
1、常用的几个IO函数 #include <unistd.h> read(); write(); #include <sys/socket.h> recv(); send(); recvmsg(); sendmsg(); #include <sys/uio.h> readv(); writev(); 2、IO函数的比较 3、IO函数的参数详解 ...原创 2020-03-12 19:42:50 · 162 阅读 · 0 评论 -
协议处理函数
协议处理函数: #include <netdb.h> struct protoent *getprotobyname (const char *); struct protoent *getprotobynumber (int); struct protoent *getprotoent (void); void sethostent (int); void endprotoen...原创 2020-03-09 19:06:13 · 248 阅读 · 0 评论 -
主机名称处理函数
#include <netdb.h> struct hostent *gethostbyaddr (const void *, socklen_t, int); struct hostent *gethostbyname (const char *); hostent结构体: /* Different from the linux versions - note the short...原创 2020-03-09 18:43:42 · 211 阅读 · 0 评论 -
IP地址转换函数
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int inet_aton (const char *name, struct in_addr *addr) uint32_t inet_addr (const char *name) uint32_t inet_net...原创 2020-03-08 10:24:46 · 495 阅读 · 0 评论 -
字节序转换
#include <netinet/in.h> uint32_t htonl (uint32_t hostlong) uint16_t htons (uint16_t hostshort) uint32_t ntohl (uint32_t netlong) uint16_t ntohs (uint16_t netshort) 1、主机序转网络序 (1) htonl uint32_t...原创 2020-03-07 10:34:25 · 271 阅读 · 0 评论 -
Socket API详解(2)
3、侦听客户端的连接 int listen (int socket, int n) Description: The listen function enables the socket socket to accept connections, thus making it a server socket. Arguments: (1)socket (2)n:指定等待连接的队列长度 The...原创 2020-03-06 18:46:35 · 223 阅读 · 0 评论 -
Socket API详解(1)
#include <sys/socket.h> int socket (int namespace, int style, int protocol) int bind (int socket, struct sockaddr *addr, socklen_t length) int listen (int socket, int n) int accept (int socket,...原创 2020-03-04 19:07:46 · 414 阅读 · 0 评论 -
TCP网络编程
#include <stdio.h> #include <stdlib.h> #include <strings.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> #include <netinet/in.h> #includ...原创 2020-03-04 14:18:39 · 141 阅读 · 0 评论
分享