我写了一个简单的 go 程序,它在 windows 上运行并测试远程端口是否处于事件状态:
package main
import (
"fmt"
"net"
)
func main(){
conn, err := net.Dial("tcp", "192.168.23.191:3403")
if err != nil {
fmt.Println(err)
} else {
conn.Close()
}
}
现在,远程端口已关闭。第一次运行,报错:
dial tcp 192.168.23.191:3403: ConnectEx tcp: The remote computer refused the network connection.
然后我继续运行,报错改为:
dial tcp 192.168.23.191:3403: ConnectEx tcp: The semaphore timeout period has expired.
为什么 Dial 返回“ConnectEx tcp:信号量超时期限已过期。”?这个错误是什么意思?
最佳答案
对 net.Dial()
的调用超时。
如图所示 here , Dialer
结构有一个 Timeout
字段定义 Dial()
等待连接的最长时间完成。
关于windows - "ConnectEx tcp: The semaphore timeout period has expired."是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22163635/