UNP学习记录总结
文章平均质量分 86
作者采用和APUE篇相同的学习方式,继续深入网络编程部分
LoveStackover
大龄码农,依然坚持,脚踏实地,不放弃梦想。
展开
-
网络编程之Client/Server Design 惊群分析篇(五)
前言 上一篇中提到了惊群现象,笔者本篇将非常严谨的记录关于惊群的一系列问题,同样根据UNP的编排进行。 1. thundering herd When the program starts, N children are created, and all N call accept and all are put to sleep by the kernel (line ...原创 2018-04-18 19:57:26 · 93 阅读 · 0 评论 -
网络编程之Client/Server Design Prefork Server(四)
1. 基本概念 提前fork若干的client形成一个children pool,但是很显然这样做很耗费资源,如何动态分配也是比较麻烦的地方,UNP给出了该server模型最简单的实现,笔者稍微做了修改。 2. 代码分析 #include <sys/socket.h> #include <sys/un.h> #include <stdlib.h&am原创 2018-04-13 16:51:35 · 54 阅读 · 0 评论 -
网络编程之Client/Server Design Concurrent Server(三)
1. 代码展示 #include <sys/socket.h> #include <sys/un.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ar原创 2018-04-11 20:30:45 · 65 阅读 · 0 评论 -
网络编程之Client/Server Design Testbench(二)
1. 前言 UNP中给出了一个简单的testbench的模型,笔者也会根据该模型,略微修改后,最为自己的testbench使用。不得不提到UNP给出的testbench的缺点:手动键入crtl+c结束测试,这将给测试带来非常大的不准确性。 2. 笔者自己的版本 #include <sys/socket.h> #include <sys/un.h> #inc...原创 2018-04-11 20:16:59 · 66 阅读 · 0 评论 -
网络编程之I_O Multiplexing总结(四)
1. 概念澄清 1.1 A socket is ready for reading if any of the following four conditions is true: The read half of the connection is closed (i.e., a TCP connection that has received a FIN). A...原创 2018-03-15 16:35:56 · 138 阅读 · 0 评论 -
网络编程之Sockets Introduction(二)
1. inet_aton, inet_addr, and inet_ntoa Functions #include <arpa/inet.h> int inet_aton(const char *strptr, struct in_addr *addrptr); Returns: 1 if string was valid, 0 on error in_addr_t inet_a...原创 2021-01-19 15:44:46 · 227 阅读 · 0 评论 -
网络编程之Sockets Introduction(一)
前言 一直在想该怎么记录UNP篇,最后我想我要锻炼自己归纳总结的能力,抓重点,抓应用。 1. introdution 本章主要分析了地址结构体的相关API函数,及2进制和字符串形式的地址之间的转化函数,最后这些地址转换函数依赖于具体的IP协议,UNP中提出了自己的以sock_开头的地址转换函数,其不依赖于具体的协议。 These structures can be ...原创 2021-01-19 15:44:25 · 245 阅读 · 0 评论 -
网络编程之Elementary TCP Sockets(二)
1. fork and exec Functions 笔者在APUE中比较详细的记录过fork函数,这里相关细节不在赘述,只看看和网络编程相关的概念: The parent calls accept and then calls fork. The connected socket is then shared between the parent and child. Nor...原创 2021-01-19 15:44:00 · 237 阅读 · 0 评论 -
网络编程之Elementary TCP Sockets(一)
1. socket #include <sys/socket.h> int socket(int family, int type, int protocol); Returns: non-negative descriptor if OK, −1 on error 上表就是对该函数的一个总结,在APUE篇笔者也记录过该内容,在此不赘述,上表没有反映出来的几点需要注意下...原创 2021-01-19 15:43:43 · 417 阅读 · 0 评论