Golang是否支持TCP同时打开?

huangapple go评论76阅读模式
英文:

Does golang support TCP simultaneous open?

问题

Go标准库的"net"包支持TCP同时打开吗?我指的是两个主机主动打开一个TCP连接并建立一个连接。我使用了net.Dialer和Dial,但是得到了连接被拒绝的错误。

英文:

Does go standard "net" package support TCP simultaneous open? I mean two hosts actively open a tcp connection to each other and build one connection. I used net.Dialer and Dial but got connection refused.

答案1

得分: 4

同时打开不是一种功能,而是如果两个客户端尝试同时连接对方时可能发生的情况。因此,通过支持正常的TCP操作,Go语言自然也支持这一点。你可能遇到连接被拒绝的原因是因为时间要非常精确。双方都必须在对方的SYN到达之前向内核注册他们的处理程序。对于同一网络中的两个客户端(比如在同一建筑物或同一校园中),这种延迟将非常低,因此窗口将非常小(最多几十毫秒)。

英文:

Simultaneous open isn't a feature, but rather something that can happen if two clients try connecting to each other at the same time. So Go supports this just by virtue of supporting the normal TCP operations. The reason you're probably getting connection refused is that the timing has to be very precise. Both sides have to register their handlers with the kernel before the other side's SYN arrives. For two clients on the same network (say in the same building or on the same campus), this latency will be incredibly low, and the window will thus be very small (a few tens of milliseconds at most).

huangapple
  • 本文由 发表于 2014年9月12日 16:54:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/25804368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定