Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

转发的 go func 部分的疑问 #80

Open
leewi9 opened this issue Apr 11, 2021 · 0 comments
Open

转发的 go func 部分的疑问 #80

leewi9 opened this issue Apr 11, 2021 · 0 comments

Comments

@leewi9
Copy link

leewi9 commented Apr 11, 2021

	// 进行转发
	 // 从 proxyServer 读取数据发送到 localUser
	go func() {
		err := proxyServer.DecodeCopy(userConn)
		if err != nil {
			// 在 copy 的过程中可能会存在网络超时等 error 被 return,只要有一个发生了错误就退出本次工作
			 userConn.Close()
			proxyServer.Close()
		}
	}()
	// 从 localUser 发送数据发送到 proxyServer,这里因为处在翻墙阶段出现网络错误的概率更大
	 userConn.EncodeCopy(proxyServer)

为什么这里两个转发,前一个用了goroutine,后一个没有用呢?

同理,在server里面也是

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

No branches or pull requests

1 participant