Merge pull request #42 from tshepang/master

tcp server example: peer address already available, so use it
This commit is contained in:
Stjepan Glavina 2020-04-28 04:29:52 -07:00 committed by GitHub
commit 1772ebe795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -32,8 +32,8 @@ fn main() -> io::Result<()> {
// Accept clients in a loop.
loop {
let (stream, _) = listener.accept().await?;
println!("Accepted client: {}", stream.get_ref().peer_addr()?);
let (stream, peer_addr) = listener.accept().await?;
println!("Accepted client: {}", peer_addr);
// Spawn a task that echoes messages from the client back to it.
Task::spawn(echo(stream)).unwrap().detach();