我正在创建与服务器的 TCP 连接,但我需要指定超时。
我怎样才能做到这一点?
这是简化的代码:
tcpserveraddr, err := net.ResolveTCPAddr("tcp", Serveraddr+":"+Serverport)
if err != nil {
log.Printf("error during address relolution: %v\n", err)
}
serversocket, err := net.DialTCP("tcp", nil, tcpserveraddr)
if err != nil {
log.Printf("error during serversocket.DialTCP(): %v\n", err)
}
www说
相关分类