-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor usage of
SocketAddr
(#2088)
* Remove unnecessary reference for parameter Not needed because `u16` implements `Copy`. * Replace `.to_socket_addrs` with `lookup_host` The `ToSocketAddrs::to_socket_addrs` function performs a blocking DNS lookup, so it should be avoided in asynchronous tasks. It can be replaced by `tokio::net::lookup_host` which receives a `tokio::net::ToSocketAddrs` implementation. * Change address parameter to be generic Don't force a string to be built, which then needs to be parsed into a `SocketAddr`. * Use `(String, u16)` instead of a raw `String` Avoid having to format the string to include the port, which will then get parsed out later. * Create a `SocketAddr` directly from integers Avoid parsing the IP address and port. * Avoid parsing `SocketAddr` if not needed Let the IP address be parsed by Tokio, and avoid formatting a string just to include the port which will get parsed out again later.
- Loading branch information
Showing
5 changed files
with
29 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters