【发布时间】:2023-01-30 00:16:37
【问题描述】:
我正在尝试构建一个 bittorrent 客户端。我编写此函数是为了验证我是否可以建立连接以向其他对等方发送消息,但它不起作用。
func handShake(torrent *gotorrentparser.Torrent, peer Peer, peedId []byte) {
conn,err := net.Dial("tcp", peer.ip + ":" + strconv.Itoa(int(peer.port)))
if err != nil {
panic(err)
}
defer conn.Close()
}
这里的 peer 是字符串 ip 和 uint16 端口的结构。
出现以下错误: panic: dial tcp 152.57.73.47:27569: connectex: A connection attempt failed because the connected party didn't properly respond after a period time, or established connection failed because connected host has failed respond.
找不到任何类似的问题。我试图将我的本地端口地址修复为与我用来发送公告请求的地址相同,但这也没有用。
编辑:我尝试使用不同的种子,它对一些同行失败了,但现在它正在为其他一些同行工作。只有当对等方将 utorrent 用作 bittorrent 客户端时才会出现问题吗?
【问题讨论】:
-
你弄错了 IP,弄错了端口,没有从“这里到那里”和/或“那里到这里”的网络路由,或者服务器没有运行。
-
如果我从追踪器那里收到它怎么会错呢?
-
在这一点上,我建议使用 wireshark 来找出网络中真正发生的事情。
-
连接被防火墙阻止或使用 127.0.0.1 或 IP 的任何本地地址。因为代码没有错。
-
“我从追踪器那里收到的,怎么会错呢?”追踪器经常出错
标签: go tcp p2p bittorrent