Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

重复请求不会重用tcp连接 #10

Open
zhwei820 opened this issue May 19, 2018 · 0 comments
Open

重复请求不会重用tcp连接 #10

zhwei820 opened this issue May 19, 2018 · 0 comments

Comments

@zhwei820
Copy link

运行前查看本机端口占用情况:

ss -ant|grep -v State|awk '{ print $1}'|sort|uniq -c
20 ESTAB
26 LISTEN
6 SYN-SENT
3 TIME-WAIT

测试程序

package main

import (
	"github.com/smallnest/goreq"
	"time"
)

func run()  {
	resp, body, err := goreq.New().Get("http://192.168.1.101:9799").End()
	println(resp)
	println(body)
	println(err)
	resp.Body.Close()

}
func main() {
	for ii:=0; ii<1000; ii++{
		time.Sleep(10 * time.Millisecond)
		go run()
	}
	select {
			// 等待手动退出
	}
}


运行后(还未退出):
ss -ant|grep -v State|awk '{ print $1}'|sort|uniq -c
1014 ESTAB <== socket还是连接状态
26 LISTEN
49 SYN-SENT
84 TIME-WAIT

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant