version negotiation

This commit is contained in:
nora 2022-02-09 11:25:16 +01:00
parent b2e6e96698
commit b77788329c
5 changed files with 107 additions and 8 deletions

View file

@ -1,10 +1,22 @@
use anyhow::{Context, Result};
use tokio::io::AsyncWriteExt;
mod connection;
use crate::connection::Connection;
use anyhow::Result;
use tokio::net;
use tracing::info;
pub async fn do_thing_i_guess() -> Result<()> {
tokio::io::stdout()
.write(b"hello async world lol\n")
.await
.context("failed to write")
.map(drop)
info!("Binding TCP listener...");
let listener = net::TcpListener::bind(("127.0.0.1", 5672)).await?;
info!(addr = ?listener.local_addr()?, "Successfully bound TCP listener");
loop {
let (stream, _) = listener.accept().await?;
info!(local_addr = ?stream.local_addr(), "Accepted new connection");
let connection = Connection::new(stream);
tokio::spawn(connection.start());
}
}