sbstp / rust-igd

Internet Gateway Device (UPNP) client
https://docs.rs/igd/
MIT License
105 stars 41 forks source link

Add udp socket read timeout #15

Closed canndrew closed 8 years ago

canndrew commented 8 years ago

search_gateway_from can block forever without any way to kill it. This sets a one second timeout waiting for a response from the gateway. An alternative would be to add something like

search_gateway_from_timeout(ip: Ipv4Addr, timeout: Duration)

Although realistically if the gateway doesn't respond after one second it's unlikely to ever respond.

sbstp commented 8 years ago

This is a needed changed indeed, my only concern is that the crate currently builds on stable and it won't build anymore with this change.

sbstp commented 8 years ago

Could you but this behind an unstable feature that is disabled by default? Then you can just enable the feature in crust.

sbstp commented 8 years ago

Also I think that allowing the user to configure the timeout would be nice. I'd add search_gateway_timeout and search_gateway_from_timeout.

canndrew commented 8 years ago

Done and done.

sbstp commented 8 years ago

Oh I just realized that you removed the timeouts for the the functions without configurable timeouts. Leaving 1 second for those would have been fine. No worries, I'll add them when the timeouts are stabilized.