This commit is contained in:
TenderIronh
2023-05-07 20:42:06 +08:00
parent cd415e7bf4
commit b667e5b766
12 changed files with 34 additions and 25 deletions
+2 -2
View File
@@ -18,9 +18,9 @@ func UDPWrite(conn *net.UDPConn, dst net.Addr, mainType uint16, subType uint16,
return conn.WriteTo(msg, dst)
}
func UDPRead(conn *net.UDPConn, timeout int) (ra net.Addr, head *openP2PHeader, result []byte, len int, err error) {
func UDPRead(conn *net.UDPConn, timeout time.Duration) (ra net.Addr, head *openP2PHeader, result []byte, len int, err error) {
if timeout > 0 {
deadline := time.Now().Add(time.Millisecond * time.Duration(timeout))
deadline := time.Now().Add(timeout)
err = conn.SetReadDeadline(deadline)
if err != nil {
gLog.Println(LvERROR, "SetReadDeadline error")