Skip to content

Commit a96edc5

Browse files
committed
replace newcoder linux and apue
1 parent a8feb82 commit a96edc5

File tree

16 files changed

+689
-711
lines changed

16 files changed

+689
-711
lines changed

为了工作/Linux/用户层/UNIX 环境高级编程.md

Lines changed: 155 additions & 155 deletions
Large diffs are not rendered by default.

为了工作/Linux/用户层/牛客 Linux.md

Lines changed: 368 additions & 368 deletions
Large diffs are not rendered by default.

实验室/本科/工作记录/10-28.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,51 @@
44

55
- 原因:`LString``length()`接口返回中文多字节字符的长度是时候出现了问题(不是网络模块的问题)
66

7-
<img src="https://img-blog.csdnimg.cn/4c8b3c9766fb447abb7c54c2d3f6273a.png" alt="image-20231028095754992" style="zoom:80%;" />
7+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028095754992.png" alt="image-20231028095754992" style="zoom:80%;" />
88

99
- 解决:在`LTcpSocket`类中修改`sends()`函数的代码,改用`std::string().size()``Udp`部分也同步修改
1010

11-
<img src="https://img-blog.csdnimg.cn/07ca008b68064946b92ff8cdd1428119.png" alt="image-20231028095937250" style="zoom:67%;" />
11+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028095937250.png" alt="image-20231028095937250" style="zoom:67%;" />
1212

13-
<img src="https://img-blog.csdnimg.cn/3b67d47886254ca29efb672da40d1bfc.png" alt="image-20231028100135626" style="zoom:67%;" />
13+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028100135626.png" alt="image-20231028100135626" style="zoom:67%;" />
1414

1515
- 测试:在`LTcpDemo``test2()`函数中
1616

17-
![image-20231028100303771](https://img-blog.csdnimg.cn/b0d92b1c7a0b474084fd502680957959.png)
17+
![image-20231028100303771](https://image.davidingplus.cn/images/2025/02/01/image-20231028100303771.png)
1818

19-
![image-20231028100313875](https://img-blog.csdnimg.cn/cd4cd2075ed94fd69fc128b1521f0030.png)
19+
![image-20231028100313875](https://image.davidingplus.cn/images/2025/02/01/image-20231028100313875.png)
2020

2121
## 2.18836:LAbstractSocket的setbufferSize和bufferSize的注释 与实际功能不太相符
2222

2323
- 原因:"接收"敲错了
2424

2525
- 解决:头文件和源文件的对应部分已修改
2626

27-
<img src="https://img-blog.csdnimg.cn/2424668159e34729bc6c2ea5bd20f710.png" alt="image-20231028100610343" style="zoom:67%;" />
27+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028100610343.png" alt="image-20231028100610343" style="zoom:67%;" />
2828

29-
<img src="https://img-blog.csdnimg.cn/08b74e1c9cd04a159f5d7e90719ad24a.png" alt="image-20231028100621069" style="zoom:67%;" />
29+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028100621069.png" alt="image-20231028100621069" style="zoom:67%;" />
3030

3131
## 3.18947:LTcpSocket的客户端buffer=0 调用receives接收服务端的消息后 程序抛出异常并崩溃
3232

3333
- 疑问:程序走到这个地方,我提前做了判断并且抛出异常的操作,如果符合我的判断,程序理应抛出异常并且结束啊,个人认为这一条`bug`不是很合理,当然我自己做了捕获异常的话那当然是没问题的
3434

3535
- 测试:在`LTcpDemo``test2()`中我设置了设置缓冲区大小为0,做了异常处理,异常被正常捕获,程序后续也正常进行
3636

37-
![image-20231028104505420](https://img-blog.csdnimg.cn/e8aced335d76474c81352830246285ad.png)
37+
![image-20231028104505420](https://image.davidingplus.cn/images/2025/02/01/image-20231028104505420.png)
3838

39-
![image-20231028104510539](https://img-blog.csdnimg.cn/b0b4a8daaa7044e8a3b0f44bbe764741.png)
39+
![image-20231028104510539](https://image.davidingplus.cn/images/2025/02/01/image-20231028104510539.png)
4040

4141
## 4.18948:建议给LAbstractSocket的buffer初始化一个合适的大小
4242

4343
- 解决:设置为`C`标准`IO`库给出的缓冲区大小`BUFSIZ`(`8192`)
4444

45-
<img src="https://img-blog.csdnimg.cn/ef9e670db0354449aab6c6ee89730cd2.png" alt="image-20231028104804232" style="zoom:67%;" />
45+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028104804232.png" alt="image-20231028104804232" style="zoom:67%;" />
4646

4747
- 测试:在`LTcpDemo``test2()`中我不给`buffersize`设置任何值(假设我是用户,我忘了),看程序是否正常运行
4848

49-
![image-20231028100303771](https://img-blog.csdnimg.cn/b0d92b1c7a0b474084fd502680957959.png)
49+
![image-20231028100303771](https://image.davidingplus.cn/images/2025/02/01/image-20231028100303771.png)
5050

51-
![image-20231028100313875](https://img-blog.csdnimg.cn/cd4cd2075ed94fd69fc128b1521f0030.png)
51+
![image-20231028100313875](https://image.davidingplus.cn/images/2025/02/01/image-20231028100313875.png)
5252

5353
## 5.18832:LAbstractSocket的peerAddress在整个通信过程中获取对方地址时 返回错误
5454

@@ -58,70 +58,70 @@
5858

5959
- 测试:`LTcpDemo``test3()`中我分别在相对`sends()``receives()`的各个位置都获取了`peerAddress()`的信息
6060

61-
![image-20231028132431843](https://img-blog.csdnimg.cn/c3c89c546635424aa3a4156898c182ea.png)
61+
![image-20231028132431843](https://image.davidingplus.cn/images/2025/02/01/image-20231028132431843.png)
6262

63-
![image-20231028132442537](https://img-blog.csdnimg.cn/ef3b4b3293cd460ea1d3cf3d19c96e74.png)
63+
![image-20231028132442537](https://image.davidingplus.cn/images/2025/02/01/image-20231028132442537.png)
6464

6565
## 6.18923:LHostAddress的getAddress 建议调整其内部处理
6666

6767
- 解决:已做内部处理,地址类型为`Unknown`的时候返回了空指针
6868

69-
<img src="https://img-blog.csdnimg.cn/a04fd4a079494c4f8e01ac56dcf3fcf2.png" alt="image-20231028132306772" style="zoom:67%;" />
69+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028132306772.png" alt="image-20231028132306772" style="zoom:67%;" />
7070

7171
## 7.18862:LHttpReply和LHttpRequest的url()返回的数据不完整
7272

7373
- 原因:在返回url的时候未考虑协议和端口号的显示
7474

7575
- 解决:在`LHttpRequest``LHttpReply`类的`url()`接口中需要补充对协议和端口
7676

77-
<img src="https://img-blog.csdnimg.cn/568e97fd83e342b3b5c533228eb95338.png" alt="image-20231028172035316" style="zoom:67%;" />
77+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028172035316.png" alt="image-20231028172035316" style="zoom:67%;" />
7878

79-
<img src="https://img-blog.csdnimg.cn/d10dc942c6274d82bacfead8ed350ea5.png" alt="image-20231028172048947" style="zoom:67%;" />
79+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028172048947.png" alt="image-20231028172048947" style="zoom:67%;" />
8080

8181
当然`LHttpReply`当中虽然有`m_pData`,但是完全没有管端口,我增添了了一个接口`setPort()`,和`setUrl()`对应
8282

83-
<img src="https://img-blog.csdnimg.cn/1e863ef61b9f4fa087912fb3424b4ef7.png" alt="image-20231028172254826" style="zoom:67%;" />
83+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028172254826.png" alt="image-20231028172254826" style="zoom:67%;" />
8484

8585
`LHttpControl`的各种类型的请求收到回复的时候都调用了`setPort()`这个方法,下面是`get`的例子
8686

87-
<img src="https://img-blog.csdnimg.cn/5d7337cad3944dd791fa3ab1bb77895f.png" alt="image-20231028172419350" style="zoom:67%;" />
87+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028172419350.png" alt="image-20231028172419350" style="zoom:67%;" />
8888

8989
- 测试:在`HttpRequestDemo``test2()`中,先用公司的,他的那个测试代码是80端口,但是他的数据有丢失,这个`bug`我还没修
9090

91-
<img src="https://img-blog.csdnimg.cn/1a0e9de366a8451eb25c4c9b22d692a5.png" alt="image-20231028172530119" style="zoom: 67%;" />
91+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028172530119.png" alt="image-20231028172530119" style="zoom: 67%;" />
9292

9393
为了测试端口不为80,我下面用了我自己的云服务器测试
9494

9595
`url`为:http://139.155.152.242:8080/test
9696

97-
<img src="https://img-blog.csdnimg.cn/72b0f8cb066f4278b337e2ef2e4c476e.png" alt="image-20231028172757806" style="zoom:67%;" />
97+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028172757806.png" alt="image-20231028172757806" style="zoom:67%;" />
9898

9999
请求结果如下:
100100

101101
协议和端口都显示出来了,这个的数据又全部请求到了,有点奇怪...
102102

103-
<img src="https://img-blog.csdnimg.cn/6abbaae33b6a4d679b7ade5d0307ff62.png" alt="image-20231028172859801" style="zoom:67%;" />
103+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028172859801.png" alt="image-20231028172859801" style="zoom:67%;" />
104104

105105
## 8.18738:LAbstractSocket的Lsocket函数名有误
106106

107107
- 解决:将函数名更改为`createSocket()`
108108

109-
<img src="https://img-blog.csdnimg.cn/11f7a40ab3284b9980b893b40a1bdaa0.png" alt="image-20231028173756696" style="zoom:67%;" />
109+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028173756696.png" alt="image-20231028173756696" style="zoom:67%;" />
110110

111111
## 9.18811:LUdpSocket的sends(unsigned char\* data,int length) 数据长度设置为0 在接收时程序崩溃
112112

113113
- 疑惑:在我这边的测试程序中跑出来正常,这条`bug`可能有问题
114114

115115
- 测试:在`LUdpDemo``test2()`中,按照`bug`的指示进行了重现
116116

117-
![image-20231028175300871](https://img-blog.csdnimg.cn/f56308a35f5c4e94ac1606c56c9f3944.png)
117+
![image-20231028175300871](https://image.davidingplus.cn/images/2025/02/01/image-20231028175300871.png)
118118

119-
![image-20231028175307205](https://img-blog.csdnimg.cn/542de34d23e94d13854894f4c43fae79.png)
119+
![image-20231028175307205](https://image.davidingplus.cn/images/2025/02/01/image-20231028175307205.png)
120120

121121
## 10.18808:LUdpSocket的sends(unsigned char\* data,int length) 发送前未设置对方的地址 程序崩溃
122122

123123
- 疑惑:和第3条一样,我认为抛出异常程序就应该结束,我们自身作捕获异常的操作就可以了
124124
- 测试:在`LUdpDemo``test1()`中,设置对方的IP和端口的代码就在下面
125125

126-
<img src="https://img-blog.csdnimg.cn/ce90495f0f6949709a35baa65d849405.png" alt="image-20231028175508217" style="zoom:67%;" />
126+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231028175508217.png" alt="image-20231028175508217" style="zoom:67%;" />
127127

实验室/本科/工作记录/10-31.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,71 @@
66

77
- 解决:我做了一些规范,我们设置请求报文的原始标头,传入身份验证的时候就直接传入用户名和密码,不需要手动调用`base64Encode`进行编码,这个东西我们在get请求内部进行,传入用户名和密码使用的是`setCredentials`方法
88

9-
<img src="https://img-blog.csdnimg.cn/aa1b5702b92a4e9b85d0dfe4b0b7cc0f.png" alt="image-20231031193700228" style="zoom: 80%;" />
9+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031193700228.png" alt="image-20231031193700228" style="zoom: 80%;" />
1010

1111
`get`请求当中对这一块的处理如下:
1212

13-
![image-20231031193739801](https://img-blog.csdnimg.cn/cc1be685d7de47d8b40ea17a9f86bde1.png)
13+
![image-20231031193739801](https://image.davidingplus.cn/images/2025/02/01/image-20231031193739801.png)
1414

1515
- 测试:在`HttpControl`中的`testGet3()`,结果如下:
1616

17-
<img src="https://img-blog.csdnimg.cn/557e689f7f114aa4a8ee774664ae3e35.png" alt="image-20231031193859647" style="zoom:67%;" />
17+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031193859647.png" alt="image-20231031193859647" style="zoom:67%;" />
1818

1919
## 2.18917:建议完善LHttpRequest的base64Encode函数的注释
2020

2121
- 原因:是之前没有对用户名和密码到底怎么传入的说的不是很清楚,结合1查看;这个东西我更倾向于是一个私有函数,因为他是被我们的`get`调用的,然后用户使用`setCredentials`方法进行设置用户名和密码,在`get`请求当中会自动调用这个方法进行编码并且加入`Http`请求头
2222

2323
- 解决:已完善
2424

25-
![image-20231031194201605](https://img-blog.csdnimg.cn/c0b6b98377214089b119f25a3bfedc5d.png)
25+
![image-20231031194201605](https://image.davidingplus.cn/images/2025/02/01/image-20231031194201605.png)
2626

2727
## 3.18908:LHttpRequest的setRawHeader设置短链接 设置失败
2828

2929
- 原因:在`get`请求封装`HttpReply`对象的时候,`HttpReply`类带有指针,但是没有做拷贝构造的重写,没有做深拷贝的操作
3030

31-
<img src="https://img-blog.csdnimg.cn/5f77ff24c52f4113826465c501c6baf9.png" alt="image-20231031200525383" style="zoom:80%;" />
31+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031200525383.png" alt="image-20231031200525383" style="zoom:80%;" />
3232

3333
对于`setRequest`函数,传的是一个值,这样就会创建一个新对象并且调用拷贝构造,这样在浅拷贝下就会导致两个对象公用一个数据段,因此当这个对象消亡后,`rawHeaders`中的数据自然就会被释放,这样原来的`rawHeaders`就没了...
3434

35-
![image-20231031200602821](https://img-blog.csdnimg.cn/0c492499b6d247aeb3120e563394a5a8.png)
35+
![image-20231031200602821](https://image.davidingplus.cn/images/2025/02/01/image-20231031200602821.png)
3636

3737
数据段指针和里面的数据,里面存储了`rawHeaders`
3838

39-
<img src="https://img-blog.csdnimg.cn/41059363497d42099d745308232f057a.png" alt="image-20231031200756443" style="zoom:67%;" />
39+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031200756443.png" alt="image-20231031200756443" style="zoom:67%;" />
4040

41-
<img src="https://img-blog.csdnimg.cn/52e7f0bfa59f484682cb92de26de3228.png" alt="image-20231031200805595" style="zoom:67%;" />
41+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031200805595.png" alt="image-20231031200805595" style="zoom:67%;" />
4242

4343
- 解决:对`HttpRequest`类重写拷贝构造函数和拷贝赋值函数
4444

45-
<img src="https://img-blog.csdnimg.cn/34e136d1fa974154911b7de00a8bb9a5.png" alt="image-20231031200911352" style="zoom:67%;" />
45+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031200911352.png" alt="image-20231031200911352" style="zoom:67%;" />
4646

4747
- 测试:`HttpRequest`中的`test3()`,禅道上对应了两种情况,我的代码标注了,两个返回的值都是`close`
4848

49-
<img src="https://img-blog.csdnimg.cn/ed9d1322eb604d798458fa5476905787.png" alt="image-20231031201029896" style="zoom:67%;" />
49+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031201029896.png" alt="image-20231031201029896" style="zoom:67%;" />
5050

5151
## 4.18895:LHttpRequest的setAttribute多次设置失败
5252

5353
- 原因:`Attribute``code``value`是用键值对`Map`存储的
5454

55-
<img src="https://img-blog.csdnimg.cn/61bde52a99704b35959b1541da401bec.png" alt="image-20231031204557255" style="zoom:67%;" />
55+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031204557255.png" alt="image-20231031204557255" style="zoom:67%;" />
5656

5757
而在`setAttribute`当中,原来没有考虑多次设置的情况,只是盲目的插入,因此可能`LMap`检测到对已经有的`key`进行插入就舍弃了这组数据,因此设置失败
5858

5959
- 解决:分情况讨论,当没有`key`的时候插入,有的时候就覆盖这个值
6060

61-
<img src="https://img-blog.csdnimg.cn/1aed0e37252a444586edb15f46021f02.png" alt="image-20231031204750736" style="zoom:67%;" />
61+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031204750736.png" alt="image-20231031204750736" style="zoom:67%;" />
6262

6363
- 测试:`HttpRequest`中的`test5()`,运行结果:
6464

65-
![image-20231031204826651](https://img-blog.csdnimg.cn/9607e67fee484a20b9364b1c852e4cbf.png)
65+
![image-20231031204826651](https://image.davidingplus.cn/images/2025/02/01/image-20231031204826651.png)
6666

6767
## 5.18861:确认 LHttpControl不设置任何标头值直接发送请求后的请求报文数据的完整性
6868

6969
- 解决:根据禅道上`Qt`返回的结果对相应请求标头设置了默认值
7070

71-
<img src="https://img-blog.csdnimg.cn/0090231d9047491d8441dd7323d1a861.png" alt="image-20231031205821072" style="zoom:67%;" />
71+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031205821072.png" alt="image-20231031205821072" style="zoom:67%;" />
7272

7373
- 测试:在`HttpRequest``test2()`中,结果如下,根据禅道上设置了一些请求标头的默认值:
7474

75-
<img src="https://img-blog.csdnimg.cn/81257b51fb914bf8a7d03fde5b0f8399.png" alt="image-20231031210114649" style="zoom:67%;" />
75+
<img src="https://image.davidingplus.cn/images/2025/02/01/image-20231031210114649.png" alt="image-20231031210114649" style="zoom:67%;" />
7676

0 commit comments

Comments
 (0)