You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code from open_ports_by_range will .await each is_port_open() instead of executing the is_port_open()-s in parallel. Ideally the .awaiting will be done for multiple future-s at a time using something like join_all. see: https://users.rust-lang.org/t/joinall-and-async-await/31051/9.
for port in from..to {
let is_open = self.is_port_open(port).await;
if is_open {
open_ports.push(port)
}
}
Note: if you decide to .await all ports in parallel, there might be an issue in case there's restriction of max TCP connections at the same time for some reason - not sure if that would be a real issue on some machines or not an issue at all.
The text was updated successfully, but these errors were encountered:
@nokola do you mind taking a look at my PR and let me know what you think?
I notice that changing the argument value from buffer_unordered method does not make things faster. I should maybe allow the user to change that value or update it with a sane default.
I don't mind but unfortunately I'm not qualified enough (I'm Rust noob still) to say for sure whether this code would result in the open_ports_by_range executing asynchronously or not.
Then, run open_ports_by_range(...) for say 100 ports and see if the whole app completes in ~2 seconds or ~200 seconds. If it completes fast, then all good.
Please let me know how this goes if/when you try the experiment - interested to see the results. Thanks!
The following code from
open_ports_by_range
will.await
eachis_port_open()
instead of executing theis_port_open()
-s in parallel. Ideally the.await
ing will be done for multiplefuture
-s at a time using something likejoin_all
. see: https://users.rust-lang.org/t/joinall-and-async-await/31051/9.Note: if you decide to
.await
all ports in parallel, there might be an issue in case there's restriction of max TCP connections at the same time for some reason - not sure if that would be a real issue on some machines or not an issue at all.The text was updated successfully, but these errors were encountered: