Skip to content

Commit

Permalink
增加第十二章节第三、四小节
Browse files Browse the repository at this point in the history
  • Loading branch information
glbrtchen committed Jan 26, 2019
1 parent 6004911 commit 7240951
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
- [12.1.2 http.Request类型](https://github.com/hantmac/Mastering_Go_ZH_CN/tree/master/eBook/chapter12/12.1.2.md)
- [12.1.3 http.Transport类型](https://github.com/hantmac/Mastering_Go_ZH_CN/tree/master/eBook/chapter12/12.1.3.md)
- [12.2 关于TCP/IP](https://github.com/hantmac/Mastering_Go_ZH_CN/tree/master/eBook/chapter12/12.2.md)
- [12.3 关于IPv4和IPv6](https://github.com/hantmac/Mastering_Go_ZH_CN/tree/master/eBook/chapter12/12.3.md)
- [12.4 命令行工具netcat](https://github.com/hantmac/Mastering_Go_ZH_CN/tree/master/eBook/chapter12/12.4.md)

- [chapter 13 网络编程 - 构建服务器与客户端](https://github.com/hantmac/Mastering_Go_ZH_CN/tree/master/eBook/chapter13/13.0.md)
- [13.1 Go 标准库-net](https://github.com/hantmac/Mastering_Go_ZH_CN/tree/master/eBook/chapter13/13.1.md)
- [13.2 TCP 客户端](https://github.com/hantmac/Mastering_Go_ZH_CN/tree/master/eBook/chapter13/13.2.md)
Expand Down
4 changes: 3 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
* [12.1.2 http.Request类型](eBook/chapter12/12.1.2.md)
* [12.1.3 http.Transport类型](eBook/chapter12/12.1.3.md)
* [12.2 关于TCP/IP](eBook/chapter12/12.2.md)

* [12.3 关于IPv4和IPv6](eBook/chapter12/12.3.md)
* [12.4 命令行工具netcat](eBook/chapter12/12.4.md)

* [13 网络编程 - 构建服务器与客户端]
* [13.0 网络编程 - 构建服务器与客户端](eBook/chapter13/13.0.md)
* [13.1 Go 标准库-net](eBook/chapter13/13.1.md)
Expand Down
7 changes: 7 additions & 0 deletions eBook/chapter12/12.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# **关于IPv4和IPv6**

**IP协议**的第一个版本称为**IPv4**;为表示区分,最新版本的IP协议被称为**IPv6**

当前IPv4协议的主要问题是IP地址即将耗尽,这也是创建IPv6协议的主要原因。IPv4协议地址耗尽的原因是一个IPv4地址只使用32位来表示,它可以表示出2的32次方(4294967296)个不同的IP地址。而IPv6使用128位定义一个地址。

IPv4地址的格式为```10.20.32.245```(用点分隔的四段),而IPv6地址的格式为```3fce:1706:4523:3:150:f8ff:fe21:56cf```(用冒号分隔的八段)。
17 changes: 17 additions & 0 deletions eBook/chapter12/12.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# **命令行工具netcat**

命令行工具```nc(1)```,全称```netcat(1)```,在测试TCP/IP的客户端和服务端时非常便利。本节将介绍它的一些常见用法。

```nc(1)```可以作为TCP服务的客户端使用,例如,作为客户端连接监听在端口```1234```的服务器主机```10.10.1.123```,命令如下:

> ```shell
> nc 10.10.1.123 1234
> ```
命令行工具```nc(1)```默认使用TCP协议。如果使用UDP协议,可以在执行```nc(1)```命令时携带```-u```参数。
如果要使用```netcat(1)```模拟服务器,可以携带```-l```参数,```netcat(1)```将监听指定端口号的连接。
如果希望```netcat(1)```生成详细的输出,可以使用```-v``````-vv```参数,这些输出对排查网络连接故障提供了很大的便利。
```netcat(1)```不仅可以测试HTTP应用程序,在第13章*网络编程 - 构建服务器与客户端*中,它同样可以灵活的使用,用于开发TCP和UDP协议的客户机和服务器。在本章中后续的一个例子中,````netcat(1)```将作为案例使用。

0 comments on commit 7240951

Please sign in to comment.