摘要: 来之google 收索结果 f ull 和 empty 。信号量mutex作为互斥信号量,它用于控制互斥访问缓冲池,互斥信号量初值为 1;信号量 full 用于记录当前缓冲池中“满”缓冲区数,初值为0。信号量 empty 用于记录当前缓冲池中“空”缓冲区数,初值为n。新的数据添加到缓存中后,full 阅读全文
posted @ 2019-07-01 23:14 codestacklinuxer 阅读(1270) 评论(0) 推荐(0)
摘要: 直接看代码 //后面整理相关信息 /* * This function implements the receiving procedure of RFC 793 for * all states except ESTABLISHED and TIME_WAIT. * It's called fro 阅读全文
posted @ 2019-07-01 23:13 codestacklinuxer 阅读(904) 评论(2) 推荐(0)
摘要: fork、vfork、clone之间的差异 fork/vfork/clone这三者均为系统调用,进程或线程通过这三种系统调用的某一种来创建子进程/线程, 这三种调用的底层实现均为linux内核源码kernel/fork.c中的do_fork()函数来实现,它们间的唯一的差别就是传入的参数值有差异。 阅读全文
posted @ 2019-07-01 23:12 codestacklinuxer 阅读(197) 评论(0) 推荐(0)
摘要: void tcp_rcv_established(struct sock *sk, struct sk_buff *skb, const struct tcphdr *th, unsigned int len) 主要是处理已经连理连接的输入的tcp数据包。tcp_rcv_established实际上 阅读全文
posted @ 2019-07-01 23:11 codestacklinuxer 阅读(806) 评论(0) 推荐(0)
摘要: 后面详细分析 先上传 之前总结查看源码后的总结 Nagle算法的基本定义是任意时刻,最多只能有一个未被确认的小段。所谓“小段”,指的是小于MSS尺寸的数据块,所谓“未被确认”,是指一个数据块发送出去后,没有收到对方发送的ACK确认该数据已收到。也就是没有收到ack 的时候不会再次发送数据出去。该算法 阅读全文
posted @ 2019-07-01 20:50 codestacklinuxer 阅读(807) 评论(0) 推荐(0)
摘要: shutdown 系统调用关闭连接的读数据通道 写数据通道 或者 读写数据通道; 关闭读通道:丢弃socket fd 读数据以及调用shutdown 后到达的数据; 关闭写通道:不同协议处理不同;tcp协议,将所有的数据发送完成,发送完后发送FIN; 但是为了删除套接字和释放文件描述符,我们必须使用 阅读全文
posted @ 2019-06-30 18:41 codestacklinuxer 阅读(945) 评论(0) 推荐(0)
摘要: accept 用于从指定套接字的连接队列中取出第一个连接,并返回一个新的套接字用于与客户端进行通信,示例代码如下 #include <sys/types.h> /* See NOTES */#include <sys/socket.h>int accept(int sockfd, struct so 阅读全文
posted @ 2019-06-27 21:21 codestacklinuxer 阅读(1914) 评论(0) 推荐(0)
摘要: #include <sys/types.h> /* See NOTES */#include <sys/socket.h>int listen(int sockfd, int backlog); · 参数 int sockfd :成功创建的 TCP 套接字。·int backlog :定义 TCP 阅读全文
posted @ 2019-06-27 20:53 codestacklinuxer 阅读(1508) 评论(0) 推荐(0)
摘要: connect 系统调用 分析 #include <sys/types.h> /* See NOTES */#include <sys/socket.h>int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); 阅读全文
posted @ 2019-06-27 17:12 codestacklinuxer 阅读(2989) 评论(0) 推荐(1)
摘要: 主要查看linux kernel 源码:Socket.c 以及af_inet.c文件 1.1 bind分析 #include <sys/types.h> /* See NOTES */#include <sys/socket.h>int bind(int sockfd, const struct s 阅读全文
posted @ 2019-06-27 10:00 codestacklinuxer 阅读(1397) 评论(0) 推荐(0)