Open Sega-Zero opened 5 years ago
This would be good!
Since there is no
SimplePing
instance is cached, any ping call starts with hostname resolving. In a very bad networks (I've tested on Network Link Conditioner with 30% packet loss) there might be pretty big lag between the function call an actual ip address resolved bySimplePing
.Right now I had to workaround it with my own timeout, but it would be much better, if
PlainPing
could do this kind a stuff, since it declares a timeout ability.Also, it would be much more effective to cache a resolved ip address (with some cache-control policies, of course), or, at least, return it into a completion, so a caller could use it to perform second ping slightly faster.
Hi, Sega Could you share how u fix the bid-lag problem? I appreciate it!
I made my timeout like this:
var timeout: (() -> Void)? = {
debugPrint("own timeout")
}
DispatchQueue.main.asyncAfter(deadline: .now.advanced(by: .seconds(1))) {
timeout?()
}
PlainPing.ping(address, withTimeout: 0.95) { (estimatedTime, err, resolvedIp) in
timeout = nil
debugPrint(estimatedTime, err, resolvedIp)
}
Since there is no
SimplePing
instance is cached, any ping call starts with hostname resolving. In a very bad networks (I've tested on Network Link Conditioner with 30% packet loss) there might be pretty big lag between the function call an actual ip address resolved bySimplePing
.Right now I had to workaround it with my own timeout, but it would be much better, if
PlainPing
could do this kind a stuff, since it declares a timeout ability.Also, it would be much more effective to cache a resolved ip address (with some cache-control policies, of course), or, at least, return it into a completion, so a caller could use it to perform second ping slightly faster.