Skip to content

Commit 61e873c

Browse files
committed
Merge pull request astaxie#661 from akfork/master
fix KB -> B
2 parents 4c96a29 + 613e665 commit 61e873c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

zh/08.1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Go语言中通过net包中的`DialTCP`函数来建立一个TCP连接,并返回
256256

257257
func handleClient(conn net.Conn) {
258258
conn.SetReadDeadline(time.Now().Add(2 * time.Minute)) // set 2 minutes timeout
259-
request := make([]byte, 128) // set maxium request length to 128KB to prevent flood attack
259+
request := make([]byte, 128) // set maxium request length to 128B to prevent flood attack
260260
defer conn.Close() // close connection before exit
261261
for {
262262
read_len, err := conn.Read(request)
@@ -273,7 +273,7 @@ Go语言中通过net包中的`DialTCP`函数来建立一个TCP连接,并返回
273273
conn.Write([]byte(daytime))
274274
} else {
275275
daytime := time.Now().String()
276-
conn.Write([]byte(daytime))
276+
conn.Write([]byte(daytime))
277277
}
278278

279279
request = make([]byte, 128) // clear last read content
@@ -298,7 +298,7 @@ TCP有很多连接控制函数,我们平常用到比较多的有如下几个
298298

299299
func (c *TCPConn) SetReadDeadline(t time.Time) error
300300
func (c *TCPConn) SetWriteDeadline(t time.Time) error
301-
301+
302302
用来设置写入/读取一个连接的超时时间。当超过设置时间时,连接自动关闭。
303303

304304
func (c *TCPConn) SetKeepAlive(keepalive bool) os.Error
@@ -312,7 +312,7 @@ Go语言包中处理UDP Socket和TCP Socket不同的地方就是在服务器端
312312
func ResolveUDPAddr(net, addr string) (*UDPAddr, os.Error)
313313
func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err os.Error)
314314
func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err os.Error)
315-
func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error
315+
func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error)
316316
func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err os.Error)
317317

318318
一个UDP的客户端代码如下所示,我们可以看到不同的就是TCP换成了UDP而已:

0 commit comments

Comments
 (0)