Merge pull request #186 from better0332/patch-2

DialTimeout在net库中已经没了
This commit is contained in:
astaxie
2013-04-25 05:55:29 -07:00

View File

@@ -229,7 +229,8 @@ Go语言中通过net包中的`DialTCP`函数来建立一个TCP连接并返回
### 控制TCP连接
TCP有很多连接控制函数我们平常用到比较多的有如下几个函数
func (c *TCPConn) SetTimeout(nsec int64) os.Error
#func (c *TCPConn) SetTimeout(nsec int64) os.Error
func DialTimeout(net, addr string, timeout time.Duration) (Conn, error)
func (c *TCPConn) SetKeepAlive(keepalive bool) os.Error
第一个函数用来设置连接的超时时间,客户端和服务器端都适用,当超过设置的时间时该连接就会失效。