-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
2123 lines (833 loc) · 54.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">
<link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">
<meta name="keywords" content="Hexo, NexT" />
<meta property="og:type" content="website">
<meta property="og:title" content="Richard-zhang-iOS的博客">
<meta property="og:url" content="https://github.com/Richard-zhang-iOS/Richard-zhang-iOS.github.io/index.html">
<meta property="og:site_name" content="Richard-zhang-iOS的博客">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Richard-zhang-iOS的博客">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Pisces',
version: '5.1.4',
sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
fancybox: true,
tabs: true,
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
duoshuo: {
userId: '0',
author: '博主'
},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<link rel="canonical" href="https://github.com/Richard-zhang-iOS/Richard-zhang-iOS.github.io/"/>
<title>Richard-zhang-iOS的博客</title>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
<div class="container sidebar-position-left
page-home">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Richard-zhang-iOS的博客</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle"></p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
首页
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
归档
</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br />
分类
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
标签
</a>
</li>
<li class="menu-item menu-item-about">
<a href="/about/" rel="section">
<i class="menu-item-icon fa fa-fw fa-user"></i> <br />
关于
</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="https://github.com/Richard-zhang-iOS/Richard-zhang-iOS.github.io/2018/12/17/Git-使用技巧/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Richard-zhang-iOS">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.png">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Richard-zhang-iOS的博客">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/12/17/Git-使用技巧/" itemprop="url">git操作总结</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2018-12-17T22:27:13+08:00">
2018-12-17
</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/计算机基础/" itemprop="url" rel="index">
<span itemprop="name">计算机基础</span>
</a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="Reset"><a href="#Reset" class="headerlink" title="Reset"></a>Reset</h2><h3 id="reset-的本质:移动-HEAD-以及它所指向的-branch"><a href="#reset-的本质:移动-HEAD-以及它所指向的-branch" class="headerlink" title="reset 的本质:移动 HEAD 以及它所指向的 branch"></a>reset 的本质:移动 HEAD 以及它所指向的 branch</h3><p>实质上,<strong>reset</strong> 这个指令虽然可以用来撤销 <strong>commit</strong> ,但它的实质行为并不是撤销,而是移动 <strong>HEAD</strong> ,并且「捎带」上 <strong>HEAD</strong> 所指向的 <strong>branch</strong>(如果有的话)。也就是说,<strong>reset</strong> 这个指令的行为其实和它的字面意思 “<strong>reset</strong>“(重置)十分相符:它是用来重置 <strong>HEAD</strong> 以及它所指向的 <strong>branch</strong> 的位置的。</p>
<p>而 <strong>reset –hard HEAD^</strong> 之所以起到了撤销 <strong>commit</strong> 的效果,是因为它把 <strong>HEAD</strong> 和它所指向的 branch 一起移动到了当前 <strong>commit</strong> 的父 <strong>commit</strong> 上,从而起到了「撤销」的效果:</p>
<p><img src="https://upload-images.jianshu.io/upload_images/4428238-6dbab74ae9ad2e1f?imageMogr2/auto-orient/strip|imageView2/2/w/466/format/webp" alt="img"></p>
<p>git reset</p>
<p>Git 的历史只能往回看,不能向未来看,所以把 <strong>HEAD</strong> 和 <strong>branch</strong> 往回移动,就能起到撤回 <strong>commit</strong> 的效果。</p>
<p>所以同理,<strong>reset –hard</strong> 不仅可以撤销提交,还可以用来把 <strong>HEAD</strong> 和 <strong>branch</strong> 移动到其他的任何地方。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git reset --hard branch2</span><br></pre></td></tr></table></figure>
<p><img src="https://upload-images.jianshu.io/upload_images/4428238-71f7141a3878da7e?imageMogr2/auto-orient/strip|imageView2/2/w/434/format/webp" alt="img"></p>
<p>git reset –hard branch2</p>
<h3 id="reset三种模式区别和使用场景"><a href="#reset三种模式区别和使用场景" class="headerlink" title="reset三种模式区别和使用场景"></a>reset三种模式区别和使用场景</h3><h4 id="区别:"><a href="#区别:" class="headerlink" title="区别:"></a>区别:</h4><ol>
<li><strong>–hard</strong>:重置位置的同时,直接将 <strong>working Tree工作目录</strong>、 <strong>index 暂存区</strong>及 <strong>repository</strong> 都重置成目标<strong>Reset</strong>节点的內容,所以效果看起来等同于清空暂存区和工作区。</li>
<li><strong>–soft</strong>:重置位置的同时,保留<strong>working Tree工作目录</strong>和<strong>index暂存区</strong>的内容,只让<strong>repository</strong>中的内容和 <strong>reset</strong> 目标节点保持一致,因此原节点和<strong>reset</strong>节点之间的【差异变更集】会放入<strong>index暂存区</strong>中(<strong>Staged files</strong>)。所以效果看起来就是工作目录的内容不变,暂存区原有的内容也不变,只是原节点和<strong>Reset</strong>节点之间的所有差异都会放到暂存区中。</li>
<li><strong>–mixed(默认)</strong>:重置位置的同时,只保留<strong>Working Tree工作目录</strong>的內容,但会将 <strong>Index暂存区</strong> 和 <strong>Repository</strong> 中的內容更改和reset目标节点一致,因此原节点和<strong>Reset</strong>节点之间的【差异变更集】会放入<strong>Working Tree工作目录</strong>中。所以效果看起来就是原节点和<strong>Reset</strong>节点之间的所有差异都会放到工作目录中。</li>
</ol>
<h4 id="使用场景"><a href="#使用场景" class="headerlink" title="使用场景:"></a>使用场景:</h4><ol>
<li><p><strong>–hard</strong> 要放弃目前本地的所有改变時<strong>,即去掉所有add到暂存区的文件和工作区的文件,可以执行 </strong>git reset -hard HEAD<strong> 来强制恢复git管理的文件夹的內容及状态;(2) </strong>真的想抛弃目标节点后的所有commit**(可能觉得目标节点到原节点之间的commit提交都是错了,之前所有的commit有问题)。</p>
</li>
<li><p><strong>–soft</strong>:原节点和<strong>reset</strong>节点之间的【差异变更集】会放入<strong>index暂存区</strong>中(<strong>Staged files</strong>),所以假如我们之前工作目录没有改过任何文件,也没add到暂存区,那么使用<strong>reset –soft</strong>后,我们可以直接执行 <strong>git commit</strong> 將 index暂存区中的內容提交至 <strong>repository</strong> 中。为什么要这样呢?这样做的使用场景是:假如我们想合并「当前节点」与「<strong>reset</strong>目标节点」之间不具太大意义的 <strong>commit</strong> 记录(可能是阶段性地频繁提交,就是开发一个功能的时候,改或者增加一个文件的时候就<strong>commit</strong>,这样做导致一个完整的功能可能会好多个<strong>commit</strong>点,这时假如你需要把这些<strong>commit</strong>整合成一个<strong>commit</strong>的时候)時,可以考虑使用<strong>reset –soft</strong>来让 <strong>commit</strong> 演进线图较为清晰。总而言之,<strong>可以使用–soft合并commit节点</strong>。</p>
</li>
<li><p><strong>–mixed(默认)</strong>:</p>
<p>使用完<strong>reset –mixed</strong>后,我們可以直接执行 <strong>git add</strong> 将這些改变果的文件內容加入 <strong>index 暂存区</strong>中,再执行 <strong>git commit</strong> 将 <strong>Index暂存区</strong> 中的內容提交至<strong>Repository</strong>中,这样一样可以达到合并<strong>commit</strong>节点的效果(与上面–soft合并commit节点差不多,只是多了git add添加到暂存区的操作)</p>
<p> 移除所有Index暂存区中准备要提交的文件(Staged files),我们可以执行 <strong>git reset HEAD</strong> 来 <strong>Unstage</strong> 所有已列入 <strong>Index暂存区</strong> 的待提交的文件。(有时候发现add错文件到暂存区,就可以使用命令)。</p>
<p> <strong>commit</strong>提交某些错误代码,或者没有必要的文件也被<strong>commit</strong>上去,不想再修改错误再<strong>commit</strong>(因为会留下一个错误<strong>commit</strong>点),可以回退到正确的<strong>commit</strong>点上,然后所有原节点和<strong>reset</strong>节点之间差异会返回工作目录,假如有个没必要的文件的话就可以直接删除了,再<strong>commit</strong>上去就OK了。</p>
</li>
</ol>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="https://github.com/Richard-zhang-iOS/Richard-zhang-iOS.github.io/2018/12/17/C语言复习/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Richard-zhang-iOS">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.png">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Richard-zhang-iOS的博客">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/12/17/C语言复习/" itemprop="url">C语言复习</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2018-12-17T22:27:13+08:00">
2018-12-17
</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/计算机基础/" itemprop="url" rel="index">
<span itemprop="name">计算机基础</span>
</a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="第一步"><a href="#第一步" class="headerlink" title="第一步"></a>第一步</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">#include <stdio.h></span><br><span class="line">int main()</span><br><span class="line">{</span><br><span class="line"> /* 我的第一个 C 程序 */</span><br><span class="line"> printf("Hello, World! \n");</span><br><span class="line"> return 0;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<ol>
<li>打开一个文本编辑器,添加上述代码。</li>
<li>保存文件为 <em>hello.c</em>。</li>
<li>打开命令提示符,进入到保存文件所在的目录。</li>
<li>键入 <em>gcc hello.c</em>,输入回车,编译代码。</li>
<li>如果代码中没有错误,命令提示符会跳到下一行,并生成 <em>a.out</em> 可执行文件。</li>
<li>现在,键入 <em>a.out</em> 来执行程序。</li>
<li>您可以看到屏幕上显示 <em>“Hello World”</em>。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ gcc hello.c</span><br><span class="line">$ ./a.out</span><br><span class="line">Hello, World!</span><br></pre></td></tr></table></figure>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2018/12/17/C语言复习/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="https://github.com/Richard-zhang-iOS/Richard-zhang-iOS.github.io/2018/09/30/网络之Socket和Http的区别/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Richard-zhang-iOS">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.png">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Richard-zhang-iOS的博客">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/09/30/网络之Socket和Http的区别/" itemprop="url">网络之Socket和Http区别</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2018-09-30T11:55:58+08:00">
2018-09-30
</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/iOS/" itemprop="url" rel="index">
<span itemprop="name">iOS</span>
</a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h3 id="Socket传输的定义和其特点"><a href="#Socket传输的定义和其特点" class="headerlink" title="Socket传输的定义和其特点"></a>Socket传输的定义和其特点</h3><p>所谓socket通常也称作”套接字”,实现服务器和客户端之间的物理连接,并进行数据传输,主要有UDP和TCP两个协议。Socket处于网络协议的传输层。</p>
<ul>
<li>UDP协议:广播式数据传输,不进行数据验证</li>
<li>TCP协议:传输控制协议,一种面向连接的协议,给用户进程提供可靠的全双工的字节流,</li>
</ul>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2018/09/30/网络之Socket和Http的区别/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="https://github.com/Richard-zhang-iOS/Richard-zhang-iOS.github.io/2018/09/30/网络之ACK和Ack number的区别/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Richard-zhang-iOS">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.png">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Richard-zhang-iOS的博客">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/09/30/网络之ACK和Ack number的区别/" itemprop="url">网络之ACK与Ack number的区别</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2018-09-30T11:13:05+08:00">
2018-09-30
</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/iOS/" itemprop="url" rel="index">
<span itemprop="name">iOS</span>
</a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>在三次握手发送的数据包中有两个ACK值(Acknowledgement),人们习惯一个大写,一个小写来加以区分。最近Linux运维班的老师在讲网络基础知识的时候又讲到了三次握手四次断开。我在听课的时候总是感觉这两个大小写的ACK和我以前学习网络时候理解的大小写是反着的。课余时间我就在网上查了一下这方面的资料,却看到貌似关于哪个大写哪个小写非常混乱。这样有时就会把刚学习三次握手的新手搞的晕头转向,分不清到底哪个是哪个了。<br>其实ACK也好,ack也好,只不过是个代号而已,叫他张三也行,叫他李四也没事,没有任何影响,因为咱们不会改动那个东西。就算是把名字记反了,对咱们也没有任何影响,大家知道三次握手的数据包里有这么两个东西就行了。<br>一个是确认值(Acknowledgement),为1便是确认连接。<br>另一个是确认编号(Acknowledgement Number),即接收到的上一次远端主机传来的seq然后+1,再发送给远端主机。提示远端主机已经成功接收上一次所有数据。</p>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2018/09/30/网络之ACK和Ack number的区别/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="https://github.com/Richard-zhang-iOS/Richard-zhang-iOS.github.io/2018/09/29/网络之keepalive/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Richard-zhang-iOS">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.png">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Richard-zhang-iOS的博客">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/09/29/网络之keepalive/" itemprop="url">网络之keepalive</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2018-09-29T18:15:23+08:00">
2018-09-29
</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/iOS/" itemprop="url" rel="index">
<span itemprop="name">iOS</span>
</a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>我们说到keepalive的时候,需要先明确一点,这个keepalive说的是tcp的还是http的。</p>
<p>tcp的keepalive是侧重在保持客户端和服务端的连接,一方会不定期发送心跳包给另一方,当一方端掉的时候,没有断掉的定时发送几次心跳包,如果间隔发送几次,对方都返回的是RST,而不是ACK,那么就释放当前链接。设想一下,如果tcp层没有keepalive的机制,一旦一方断开连接却没有发送FIN给另外一方的话,那么另外一方会一直以为这个连接还是存活的,几天,几月。那么这对服务器资源的影响是很大的。</p>
<p>http的keep-alive一般我们都会带上中间的横杠,普通的http连接是客户端连接上服务端,然后结束请求后,由客户端或者服务端进行http连接的关闭。下次再发送请求的时候,客户端再发起一个连接,传送数据,关闭连接。这么个流程反复。但是一旦客户端发送connection:keep-alive头给服务端,且服务端也接受这个keep-alive的话,两边对上暗号,这个连接就可以复用了,一个http处理完之后,另外一个http数据直接从这个连接走了。</p>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2018/09/29/网络之keepalive/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">