chore: cleanup test code

This commit is contained in:
Dreamacro
2022-05-21 17:37:06 +08:00
committed by 世界
parent b9e6de45e6
commit 7079116aa8
10 changed files with 161 additions and 242 deletions

View File

@@ -35,3 +35,16 @@ func ListenPacket(network, address string) (net.PacketConn, error) {
}
return nil, lastErr
}
func TCPing(addr string) bool {
for i := 0; i < 10; i++ {
conn, err := net.Dial("tcp", addr)
if err == nil {
conn.Close()
return true
}
time.Sleep(time.Millisecond * 500)
}
return false
}