Create 15.2.md

This commit is contained in:
glight2000
2015-12-09 21:18:32 +08:00
parent b5f526993f
commit 8b8d7cb483

14
eBook/15.2.md Normal file
View File

@@ -0,0 +1,14 @@
# 15.2 一个简单的网页服务器
Http是一个比tcp更高级的协议它描述了客户端浏览器如何与网页服务器进行通信。Go有自己的`net/http`包,我们来看看它。我们从一些简单的示例开始,
首先编写一个“Hello world!”:[查看示例15.6](examples/chapter_15/hello_world_webserver.go)
我们引入了`http`包并启动了网页服务器和15.1的`net.Listen("tcp", "localhost:50000")`函数的tcp服务器是类似的使用`http.ListenAndServe("localhost:8080", nil)`函数如果成功会返回空否则会返回一个错误可以指定localhost为其他地址8080是指定的端口号
## 链接
- [目录](directory.md)
- 上一章:[tcp服务器](15.1.md)
- 下一节:[写一个简单的网页应用](15.3.md)